Here we try to modify every element in the 'hash', and the result show that only values can be changed, not the keys. But doesn't this make sense? Have you ever found yourself trying to change hash keys? You can't, you have to make a new key instead:use Data::Dumper; my %h = 'a'..'f'; $_ .= '_mod' for %h; print Dumper \%h;
Now, let's take chromatic's advice and try this with an array:$h{a_mod} = delete $h{a};
Because at the time we changed the 'keys', they weren't yet keys. ;)my @h = 'a'..'f'; $_ .= '_mod' for @h; %h = @h; print Dumper \%h;
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to Re: LVALUEness in flattened hashes
by jeffa
in thread LVALUEness in flattened hashes
by calin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |