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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2017-02-23 02:07 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (338 votes). Check out past polls.