If you want the more efficient approach of for/foreach (which uses aliasing) with the readability of map, don't use the short form of for! This is about as good as map and still looks clean.
foreach $elem (@array) {
$elem = lc $elem;
}
Sadly readability (map/foreach) and efficient terse perlishness (the examples ending in for) are often not the same, and given the choice, I'd stick with the map. Yet, the foreach is much more flexible and readable in the long run, and is more readable for non-Perl folks as well. It may prove to be the best option in the long run, if not as shiny looking as the others.
|