I understand. But it would be a lot of work to write the script and take a lot of CPU time to rearrange all of the records in your .db file -- and then as soon as you modified a record, it would be out of order again.
Nevertheless, if you want to do it, you can do it.
In sub unarchive_records, after
&auth_logging("unarchived records: $succstr") if ($auth_logging);
add
Code:
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;
foreach $line (@lines) {
unless ($line =~ /^#/) {
++$line_count;
}
}
$in{$db_key} = "*";
$in{'mh'} = $line_count;
$in{'sb'} = $db_key_pos;
$output = "";
my ($status,@hits) = &query{'view'};
my ($numhits) = ($#hits+1) / ($#db_cols+1);
for (0 .. $numhits - 1) {
% rec = &array_to_hash($_, @hits); # Be sure to take out the space between % and rec
$output .= &join_encode(% rec) . "\n";
}
open (DB, ">$db_file_name") or &cgierr("error in unarchive_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
If you want to keep the records in order after they are modified, add the same code to sub modify_record, before
&auth_logging("modified record: $in{$db_key}") if ($auth_logging);
JPD