Re: Can't understand this.
- From: krahnj@xxxxxxxxx (John W . Krahn)
- Date: Thu, 29 Nov 2007 07:21:39 -0800
On Thursday 29 November 2007 06:29, AY wrote:
I'm not sure what this piece of code does: Infact it is getting a
database query and iterating ...
my %temp;
while ( my %row = $dbproc->dbnextrow(1) ){
$dbproc->dbnextrow(1) is returning a list and that list is assigned to
the lexical hash %row which is only visible inside the while loop. If
nothing is assigned to %row then %row will be false and the loop will
end.
$temp{ $row{ i } } = { %row }; // No idea what this is doing.
The value of $row{ i } is used as the key for the hash %temp and it is
assigned a hash reference by copying the hash %row into an anonymous
hash. Because the %row hash is local to the while loop you can skip
the copying and just assign a hash reference:
$temp{ $row{ i } } = \%row;
}
John
--
use Perl;
program
fulfillment
.
- References:
- Can't understand this.
- From: Ay
- Can't understand this.
- Prev by Date: Re: Cannot understand this fragment of code
- Next by Date: Re: Comparing Regular Expression in Perl vs Python
- Previous by thread: Can't understand this.
- Index(es):
Relevant Pages
|