Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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;


Comment on Re: switch, transliteration ( tr/// ) of $_ issue
Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://724402]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2014-07-14 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (253 votes), past polls