I have a curiosity maybe someone here can help with.
This code:
@a=(1,2);
map { $_ = 3 } @a;
print join(",", @a), "\n";
... prints "3,3". That map is changing the @a array as it goes through it.
Good.
Now this:
%a=(1,2);
map { $_ = 3 } keys %a;
print join(",", keys(%a)), "\n";
I expected this to print "3", but it doesn't -- it prints "1". If map sets
$_ as an alias to the value, why isn't it changing the keys?
Thanks!
- Bryan
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/