Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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

by Perlbotics (Canon)
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://942518]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2017-02-22 16:32 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (331 votes). Check out past polls.