3 ms·
How about this: map{ tr/a-z/A-Z/; print $_ }@array; I don't remember the exact syntax, but the tr acts on $_ by default, and $_ starts out
by tikhonj 15y ago
How about this:
map{
tr/a-z/A-Z/;
print $_
}@array;
I don't remember the exact syntax, but the tr acts on $_ by default, and $_ starts out as each element of the array.
- draegtun 15y agoIn 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