Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: switch, transliteration ( tr/// ) of $_ issue

by runrig (Abbot)
on Nov 18, 2008 at 22:15 UTC ( #724402=note: print w/replies, xml ) Need Help??

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

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

Replies are listed 'Best First'.
Re^2: switch, transliteration ( tr/// ) of $_ issue
by blazar (Canon) on Nov 19, 2008 at 11:40 UTC

    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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://724402]
[Corion]: On another topic, in the process of Rubber Duck SoPWing, I wrote a post about the best API for generating HTTP requests (not sending them) and while writing it and fleshing out my sample implementation, I came up with some improvements to my ...
[Corion]: ... existing prototype. Cartesian Products will be proud of that module once it gets out ;)
[Corion]: Hi marto ;)
LanX has the same problem with English accents ...
[LanX]: Will Cartesian Products still be tarif free after Brexit?
LanX ... though he can't lift more than one grown up at a time

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2017-01-18 10:21 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (161 votes). Check out past polls.