Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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.


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 musing on the Monastery: (6)
As of 2015-08-01 00:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (285 votes), past polls