Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2016-10-28 10:09 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (379 votes). Check out past polls.