Consider:
Outout:use Modern::Perl; use Data::Dump qw /dump/; my @array; for my $count (1 .. 4) { my %hash; $hash {first} = $count . ' first'; $hash {second} = $count . ' second'; push @array, \%hash; } say dump(\@array);
[ { first => "1 first", second => "1 second" }, { first => "2 first", second => "2 second" }, { first => "3 first", second => "3 second" }, { first => "4 first", second => "4 second" }, ]
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
In reply to Re: problem in Pushing to Array of hash
by CountZero
in thread problem in Pushing to Array of hash
by perl_peter
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |