in reply to Re^2: Passing an array of hashes to a subroutine
in thread Passing an array of hashes to a subroutine
No, not quite. You would need to add something to clear the hash after it's pushed.
my @array; my %hash; # ... push @array, { %hash }; %hash = (); # ... push @array, { %hash };
But I don't like it. Since the natural progression is a loop, you've just advocated the following:
my @array; my %hash; for (...) { %hash = (); # ... push @array, { %hash }; }
I much prefer the following:
my @array; for (...) { my %hash; # ... push @array, { %hash }; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Passing an array of hashes to a subroutine
by blazar (Canon) on May 22, 2007 at 10:19 UTC |