guess my previous reply didn't make sense -- i thought you were lois!
you mention the key field is 0 -- does that matter? i'm guessing from your code that the userid field is what you're matching from the first database and it occupies position 9 in the second?
here's my code:
sub getName {
# --------------------------------------------------------
my ($theID) = $_[0];
my ($db_KEY_field)=0; #<-Change this to fit your DB
open (OTHER, "<$db_other_file_name") or &cgierr("error in sub getName.... unable to open file $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
@lines = <OTHER>;
close OTHER;
LINE: foreach $line (@lines) {
if ($line =~ /^$/) { next LINE; }
if ($line =~ /^#/) { next LINE; }
chomp ($line);
@data = &split_decode($line);
if ($data[$db_KEY_field] eq $theID) {
$theID=$data[1];
last; # <- found stop processing
}
return $theID; }
}in the second db, i'm matching field 0. the data i want to retrieve is field 1. seems no matter what i change, i just get the original value of $theID. why isn't $theID=$data[1] changing the value to the value in field 1?
you mention the key field is 0 -- does that matter? i'm guessing from your code that the userid field is what you're matching from the first database and it occupies position 9 in the second?
here's my code:
Code:
sub getName {
# --------------------------------------------------------
my ($theID) = $_[0];
my ($db_KEY_field)=0; #<-Change this to fit your DB
open (OTHER, "<$db_other_file_name") or &cgierr("error in sub getName.... unable to open file $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
@lines = <OTHER>;
close OTHER;
LINE: foreach $line (@lines) {
if ($line =~ /^$/) { next LINE; }
if ($line =~ /^#/) { next LINE; }
chomp ($line);
@data = &split_decode($line);
if ($data[$db_KEY_field] eq $theID) {
$theID=$data[1];
last; # <- found stop processing
}
return $theID; }
}