in reply to array of hashes
my %h = (); foreach(@_) { $h{something} = $_; # changes the %h above every time push @something, \%h; # puts the %h into @something multiple times +... }
my %h = (); foreach(@_) { $h{something} = $_; # changes the %h above every time push @something, {%h}; # copies the accumulated changes into @somet +hing }
foreach( @_ ) { my %new_hash = (something => $_ ); # make a new hash push @something, \%new_hash; # push it onto the stack }
foreach(@_) { push @something, { something => $_ }; # make a new hash and push i +t onto @something! Magic! }
For all the details of all the nuances above, look at perldata and perlref. I re-read perlref twice a year or more. I frequently find something new.
-Paul
|
|---|