in reply to (wil) Re: Passing a hash between subs
in thread Passing a hash between subs
However now $ref only contains the hash ref from the last iteration of the while loop, or is that the desired result?sub foo { ... ## get $ref back from bar() my($ref, %locations) = &bar($dbh); ... my $location_text = $locations{$ref->{'location'}}; } sub bar { ... my $ref; while ($ref = $sth->fetchrow_hashref()) { my $id = $ref->{'id'}; my $location = $ref->{'location'}; $locations{$id} = $location; } $sth->finish; ## return $ref back to caller return $ref, %locations; }
_________
broquaint
|
---|