Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by Perlbotics (Abbot)
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.


Comment on Re^2: true/false condition - what am I doing wrong?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2014-11-23 10:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (130 votes), past polls