hi cheatah,
ich habs jetzt:
open (DB, "<$db_file_name") or &cgierr("error in archive_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
@lines = <DB>;
close DB;
LINE: foreach $line (@lines) {
if ($line =~ /^$/) { next LINE; }
if ($line =~ /^#/) { $output .= $line; next LINE; }
chomp ($line);
@data = &split_decode($line);
print "Ich vergleiche: '$today' vs '$data[$removeby_field]' ... <br>\n";
if ($today > (&date_to_unix($data[$dateadded_field]) + (86400 * $data[$removeby_field]))) {
print "Eintrag $data[0] archiviert<br>\n";
open (ARC, ">>$db_archive_name") or &cgierr("error in archive_record. unable to open database: $db_archive_name.\nReason: $!");
if ($db_use_flock) {
flock(ARC, 2) or &cgierr("unable to get exclusive lock on $db_archive_name.\nReason: $!");
}
print ARC "$line\n";
close ARC; # automatically removes file lock
}
else {
$output .= $line . "\n";
}
}
open (DB, ">$db_file_name") or &cgierr("error in archive_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) {
flock(DB, 2) or &cgierr("unable to get exclusive lock on $db_file_name.\nReason: $!");
}
print DB $output;
close DB; # automatically removes file lock
Cheatah, warum klappt das denn jetzt??
Pit