Gossamer Forum
Home : Products : DBMan : Customization :

Another record counter script BUG!

Quote Reply
Another record counter script BUG!
Ok, this is another record counter BUG.

If record has more than 255 characters (1 line) this script makes a lot of trouble.

How to avoid that ?!?

Tnx in advance...


-----------the script-----------
open (DB, "<$db_file_name")
or &cgierr("error in modify_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
@lines = <DB>; # Slurp the database into @lines..
close DB;
LINE: foreach $line (@lines) {
if ($line =~ /^$/) { next LINE; }
if ($line =~ /^#/) { $output .= $line; next LINE; }
chomp ($line);
@data = &split_decode($line);
if ($data[$db_key_pos] eq $rec{$db_key}) {
++$data[$db_counter_field];
$output .= join($db_delim, @data) . "\n";
}
else {
$output .= $line . "\n";
}
}
open (DB, ">$db_file_name")
or &cgierr("error in modify_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;
-------------------------
Quote Reply
Re: Another record counter script BUG! In reply to
Anyone ?!

tnx
Quote Reply
Re: Another record counter script BUG! In reply to
Give it a few days...JPDeni is on vacation and others may NOT know how to solve this problem.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Another record counter script BUG! In reply to
Ok, no prob... It's just this is one of many bugs in this snippet... :-(

Quote Reply
Re: Another record counter script BUG! In reply to
My suggestion, then, is that you delete the code from your script. I have not tested it. I have no way to test it, since I don't have a database set up to test it.



------------------
JPD