http://www.perlmonks.org?node_id=724554


in reply to Re: switch, transliteration ( tr/// ) of $_ issue
in thread switch, transliteration ( tr/// ) of $_ issue

No real advantage, but for completeness:

my ($bar) = map +(0,'low','med','high')[tr/I//] || 'drat', $foo; # or my ($bar) = map qw(0 low med high)[tr/I//] || 'drat', $foo;

qw helps, and "0" is false...

--
If you can't understand the incipit, then please check the IPB Campaign.