wil has asked for the wisdom of the Perl Monks concerning the following question:
$location_text returns sometimes nothing and othertimes a seemingly random value.sub foo { ... my %locations = &bar($dbh); ... my $location_text = $locations{$ref->{'location'}}; } sub bar { my $dbh = shift; my $sql_loc = qq|SELECT * FROM ndmw_location|; my $sth = $dbh->prepare($sql_loc); $sth->execute or die("..."); my %locations; while (my $ref = $sth->fetchrow_hashref()) { my $id = $ref->{'id'}; my $location = $ref->{'location'}; $locations{$id} = $location; } $sth->finish; return %locations; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Passing a hash between subs
by broquaint (Abbot) on Jan 30, 2003 at 16:24 UTC | |
by wil (Priest) on Jan 30, 2003 at 16:42 UTC | |
by broquaint (Abbot) on Jan 30, 2003 at 16:54 UTC | |
Re: Passing a hash between subs
by Cabrion (Friar) on Jan 30, 2003 at 16:49 UTC | |
Re: Passing a hash between subs
by davorg (Chancellor) on Jan 30, 2003 at 16:28 UTC | |
Re: Passing a hash between subs
by OM_Zen (Scribe) on Jan 30, 2003 at 16:48 UTC | |
Re: Passing a hash between subs
by Coruscate (Sexton) on Jan 30, 2003 at 16:58 UTC | |
Re: Passing a hash between subs
by physi (Friar) on Jan 30, 2003 at 18:45 UTC |