On Fri, Aug 24, 2001 at 03:24:46PM +0200, Birgit Kellner wrote:
> --On Donnerstag, 23. August 2001 11:03 -0800 Michael Fowler 
> <[EMAIL PROTECTED]> wrote:

> open (DB, "<$db_filname") or &cgierr("error in get_records. unable to open 
> db file: $db_file_name.\nReason: $!"); #opens ok

Is that correct?  You're opening $db_filname, but printing out $db_file_name
if there's an error.


>       if ($db_use_flock) { flock(DB, 1); }    #$db_use_flock=1
>       LINE: while (<DB>) { #reading in the file line by line
>               (/^#/)      and next LINE;
>               (/^\s*$/)   and next LINE;
>               $line = $_;     chomp ($line);
>               @data = &split_decode($line);
>               next LINE if ($restricted and ($db_userid ne 
>$data[$auth_user_field]));# 
> evaluates false
>               if ($data[$db_key_pos] eq $key) {# this is never true, but should be! 
> $db_key_pos has the correct value.
>                       $found = 1;
>                       for ($i = 0; $i <= $#db_cols; $i++) {  # Map the array columns 
>to a hash.
>                               $rec{$db_cols[$i]} = $data[$i];
>                       }
>                       last LINE;
>               }
>       }
>       close DB;       
 
> The crucial condition if ($data[$db_key_pos] eq $key) returns true if I 
> call the sub from a different place in the script. It does seem to depend 
> on whether the sub is called before (OK) or after another sub (doesn't 
> work), even though that other sub does not do anything with the database 
> file or manipulate values accessed by this sub. Very puzzling.

If $db_key_pos is correct, as you say, and $data[$db_key_pos] doesn't return
the value you expect, then it would seem @data has not been properly filled.

What is this other subroutine?

 
> Sorry if I'm not providing enough information, but it is difficult for me 
> to figure out what information you need to understand this.

Well, some Data::Dumper output (or whatever you can come up with) of your
data structures would be a start.  Related code, such as split_decode(),
this sub that you call that seems to make this chunk of code stop working,
and how and where $db_key_pos is set would all be useful things to have.


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to