in reply to Re^2: use 'local' modifier to hashref element
in thread use 'local' modifier to hashref element
The reason for your cited line from the documentation is to try to prevent people from thinking that my and local do anything even remotely similar. (That's a little hyperbole, which I can expound upon as necessary).
Update: Code is worth a thousand words.
Note the localized value associated with the key 1 is restored when you exit the block, but the (unlocalized) value associated with the key 3 is not.use strict; use warnings; use Data::Dumper; my $hash_ref = {1 => 2, 3 => 4}; BLOCK: { local $hash_ref->{1} = 5; $hash_ref->{3} = 6; print Dumper $hash_ref; } print Dumper $hash_ref;
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: use 'local' modifier to hashref element
by nbtrap (Sexton) on Jun 06, 2013 at 01:03 UTC | |
by shmem (Chancellor) on Jun 06, 2013 at 13:56 UTC | |
by jakeease (Friar) on Jun 06, 2013 at 08:07 UTC |