2 ms·
In map, $_ is a localised reference. Thus it doesn't clobber $_ my @array = qw/one two three/; $_ = "Hello"; say; map { tr/a-z/A-Z/ } @array;
by draegtun 15y ago
In map, $_ is a localised reference. Thus it doesn't clobber $_
my @array = qw/one two three/;
$_ = "Hello";
say;
map { tr/a-z/A-Z/ } @array;
say;
prints....
Hello
Hello
However remember it's a reference so using tr// will update @array...
say "@array"; # => ONE TWO THREE