Gossamer Forum
Home : Products : DBMan : Customization :

not recognizing records

Quote Reply
not recognizing records
I'm using code from the relational mod successfully but am trying something new with it. in the new situation, it doesn't seem to recognize where one record ends and the next begins. the records use split vertical pipe as field delimiter and each record starts on a new line. when my new code prints a record, it prints the entire database all run together. here's the code i'm using. the print commands are just so i can see what's happening and $key2 is just to try to match one of the records. the print statement produces the key for the first record (which is 1095) and 1001. but $line and @data both print the entire database, the first with delimiters and the second without. why doesn't it recognize the end of the first record and read the second record?
Code:
$key2 = '1001';
$found = 0;

open (DB, "<$db2_file_name") or &cgierr("error in get_records. unable to open db file: $db2_file_name.\nReason:

$!");
flock(DB, 1);
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
$line = $_;
chomp ($line);
@data = &split_decode2($line);
print qq|<p>$data[$db2_key_pos] - $key2</p>
<h1>line</h1><p>$line</p>
<h1>data</h1><p>@data</p>|;
if ($data[$db2_key_pos] eq $key2) {
$found = 1;
for ($j = 0; $j <= $#db2_cols; $j++) { # Map the array columns to a hash.
$rec2{$db2_cols[$j]} = $data[$j];
}
last LINE;

}
# $notfound .= $data[$db2_key_pos] ;
$notfound = $key2;
}
close DB;
###
Quote Reply
Re: [delicia] not recognizing records In reply to
never mind. figured out