Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

conditional statements in list constructors

by Don Coyote (Hermit)
on Mar 27, 2014 at 13:09 UTC ( #1079916=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @arr =     ( if(1<2){'1'}else{()} );          #syntax error
    my $arrref =  \( if(1<2){'1'}else{()} );         #syntax error
    ...
    ( 1<2 ? print '1',$/ : print '2',$/ );           #works
    
    ( if(1<2){print '1',$/ }else{print '2',$/} );    #syntax error
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1079916]
Approved by Limbic~Region
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2022-05-26 08:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (93 votes). Check out past polls.

    Notices?