Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2016-09-25 10:00 GMT
Find Nodes?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:

    Results (468 votes). Check out past polls.