lightoverhead has asked for the wisdom of the Perl Monks concerning the following question:
if I use
while($ref=fetchrow_arrayref()){ print "@{$ref}\n"; }
it works fine (printing all the rows I wanted).
but if I use
while($ref=fetchrow_arrayref()){ push @ary,$ref; } foreach (@ary){ print "@{$_}\n"; }
it can only print the last record several times.
Could someone explain this to me?
I know fetchrow_arrayref() has weird behavor, but can not understand why the above two code snippets generate different results.
Thanks.
|
|---|