Re:How to read Haskell like Python
by tikhonj on Monday November 14, 2011 @08:58PM
(#3236606)
How about this:
I don't remember the exact syntax, but the tr acts on $_ by default, and $_ starts out as each element of the array.
[ Parent
| on HN ]
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