Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by si_lence (Deacon)
on Dec 08, 2011 at 14:30 UTC ( #942447=note: print w/ replies, xml ) Need Help??


in reply to true/false condition - what am I doing wrong?

You can use a block construct to get this to work:

my $type = "add"; my $redo; $type eq "add" ? {$redo = "wiki_add2"} : {$redo = "wiki_edit2"}; print "With type: $type, we could redo: $redo \n";


Comment on Re: true/false condition - what am I doing wrong?
Download Code
Re^2: true/false condition - what am I doing wrong?
by trizen (Friar) on Dec 08, 2011 at 19:00 UTC
    Did you mean 'do' block? Because using your example I get the following warnings:
    Useless use of anonymous hash ({}) in void context at test.pl line 5. Useless use of anonymous hash ({}) in void context at test.pl line 5. Odd number of elements in anonymous hash at test.pl line 5.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2014-08-02 03:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (54 votes), past polls