in reply to problem in Pushing to Array of hash
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: problem in Pushing to Array of hash <SOLVED>
by perl_peter (Initiate) on Sep 28, 2011 at 14:06 UTC |