Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by runrig (Abbot)
on Nov 18, 2008 at 22:15 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-04-19 10:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found