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 } }
True laziness is hard work

Replies are listed 'Best First'.
Re^2: Modifying an array of hashes
by JavaFan (Canon) on Apr 06, 2011 at 21:24 UTC
    And even more Perlish is the use of map, low precedence and, hash slices, and list assignment (untested):
    map {$$_{name} eq 'Bob' and @{$_}{qw{name age}} = qw{Robert 42}}} @peo +ple;
      yuck!
      Yuck indeed. This will not work because
      $$_{name} eq 'Bob' and @{$_}{qw{name age}
      will at best evaluate to '' for non-Bobs.