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

Re^2: Code blocks with ternary operator or trailing conditionals

by puterboy (Scribe)
on Feb 09, 2014 at 02:48 UTC ( [id://1074085]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    perl -e 'print "hello\n" if 1'
    hello
    
  2. or download this
    perl -e '{print "hello\n"; print "bye\n"} if 1'
    Execution of -e aborted due to compilation errors.
    syntax error at -e line 1, near "if 1"
    
  3. or download this
    perl -e '1 ? print "hello1\n" : print "hello2\n" if 1'
    hello1
    
  4. or download this
    perl -e '1 ? {print "hello1\n"; print "bye1\n"} : {print "hello2\n"; p
    +rint "bye2\n"}'
    syntax error at -e line 1, near "; print"
    syntax error at -e line 1, near ""bye2\n"}"
    Execution of -e aborted due to compilation errors.
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 22:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found