Elb--
I don't think there's any reason to renumber the database, but this is something that has come up so often, I've given up trying to talk people out of it.
wallaby --
You'll need to change the part of the script that writes to the .db file. The changes are in red below:
Code:
$i = 1;
open (DB, ">$db_script_path/$db_file_name") or ("Can't open: $db_script_path/$db_file_name. Reason: $!");
if ($db_use_flock) { flock (DB, 2); }
foreach (@lines) {
next if /^#/;
next if /^\s*$/;
chomp;
@values = split (/\Q$db_delim\E/o, $_);
print "Comparing: '$today' vs '$values[$removeby_field]' ... \n";
if ($today > (&date_to_unix($values[$dateadded_field]) + (86400 * $values[$removeby_field]))) {
print "Record(s) Deleted\n";
next;
}
$values[$db_key_pos] = $i;
++$i;
$line = join "$db_delim",@values;
print DB $line, "\n";
}
close DB;
open (ID, ">$db_id_file_name") or ("unable to open id file: $db_id_file_name.\nReason: $!");
if ($db_use_flock) {
flock(ID, 2) or ("unable to get exclusive lock on $db_id_file_name.\nReason: $!");
}
print ID $i; # update counter.
close ID; # automatically removes file lock
Be sure you backup your database before you do this. It hasn't been tested, except for syntax errors.
JPD
http://www.jpdeni.com/dbman/