Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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?

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 making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2017-06-24 06:21 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (556 votes). Check out past polls.