in reply to Alias of hash-values?
Well, if hash values weren't lvalues, $h{1} = 2 wouldn't work. There's no reason why they shouldn't be lvalues when using the whole hash in list context. And any lvalues can be aliased, otherwise $_++ for ... could never work.
I'm not sure those things are explicitly documented somewhere.
The thing that surprises me though is that trying to increment the hash keys doesn't die like this one:
$ perl -wE 'my $x; $_++ for ($x, 1)' Modification of a read-only value attempted at -e line 1.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Alias of hash-values?
by Athanasius (Archbishop) on Feb 21, 2013 at 02:21 UTC | |
by LanX (Saint) on Feb 21, 2013 at 02:32 UTC | |
Re^2: Alias of hash-values?
by LanX (Saint) on Feb 20, 2013 at 16:58 UTC | |
by LanX (Saint) on Feb 20, 2013 at 22:36 UTC |
In Section
Seekers of Perl Wisdom