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 } }
In reply to Re: Modifying an array of hashes
by GrandFather
in thread Modifying an array of hashes
by erabus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |