Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: true/false condition - what am I doing wrong?

by Perlbotics (Chancellor)
on Dec 08, 2011 at 23:19 UTC ( #942518=note: print w/replies, xml ) Need Help??


in reply to Re: true/false condition - what am I doing wrong?
in thread true/false condition - what am I doing wrong?

The ternary operator is stackable. So for three choices, the following might be bearable:

use strict; use warnings; for my $type ( qw(add edit nada) ) { my $redo = $type eq 'add' ? 'wiki_add2' : $type eq 'edit' ? 'wiki_edit2' : 'error'; print "$type -> $redo\n"; } __END__ add -> wiki_add2 edit -> wiki_edit2 nada -> error

But as AM points out, the OP's task seems to call for a dispatch table.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://942518]
help
Chatterbox?
[LanX]: Nancy? Somewhere near Metz ...
[Eily]: must be km farenheit or something :P
[Eily]: wow, don't say that in Nancy LanX :P
[erix]: maybe you used the car routes, I used the walking routes
[Eily]: there's a rivalry between the two cities, so defining one in terms of the other might not be well received
[Eily]: erix well I did click on the walking icon
LanX giggles!
[LanX]: Eily I'm duing this constantly with people from rival cities ...MUCHO fun!
[Eily]: The best example of that is the TGV, they couldn't decide who would get it so it's in the middle of nowhere halfway between the two
[LanX]: Eily: that rings a bell

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (13)
As of 2017-12-13 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (369 votes). Check out past polls.

    Notices?