Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Code blocks with ternary operator or trailing conditionals

by Anonymous Monk
on Feb 09, 2014 at 09:08 UTC ( [id://1074098]=note: print w/replies, xml ) Need Help??


in reply to Code blocks with ternary operator or trailing conditionals

Just use an if...else. The ternary operator is not meant for full statements.

If I had to put them all on a single line, I'd use something like this, but you'll have to be careful of false values:

1 and print "hello1\n" and print "bye1\n" or print "hello2\n" and prin +t "bye2\n"
...That's awful in terms of style, though. Just use an if statement.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-24 09:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found