in reply to Modifying an array of hashes
There is not problem with doing that. You are not changing the contents of the array, only the contents of hashes referenced by elements of the array.
A more Perlish way to write the loop is:
for my $person (@people) { if ($person->{name} eq 'Bob') { $person->{name} = 'Robert'; # MODIFY $person->{age} = 46; # ADD } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Modifying an array of hashes
by JavaFan (Canon) on Apr 06, 2011 at 21:24 UTC | |
by ikegami (Patriarch) on Apr 06, 2011 at 22:30 UTC | |
by believer (Sexton) on Apr 11, 2011 at 13:43 UTC |