Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Warning while using ternary operator

by kcott (Abbot)
on Dec 16, 2013 at 15:19 UTC ( #1067344=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $expression ? $var = "foo" : $var = "bar";
    
  2. or download this
    $ perl -MO=Deparse,-p -e '$expression ? $var = "foo" : $var = "bar";'
    (($expression ? ($var = 'foo') : $var) = 'bar');
    -e syntax OK
    
  3. or download this
    $ perl -MO=Deparse,-p -e '$expression ? ($var = "foo") : ($var = "bar"
    +);'
    ($expression ? ($var = 'foo') : ($var = 'bar'));
    -e syntax OK
    
  4. or download this
    #!/usr/bin/env perl -l
    
    ...
        $expression ? ($var = 'foo') : ($var = 'bar');
        print "\$expression = '$expression'; \$var = '$var'";
    }
    
  5. or download this
    $expression = '0'; $var = 'bar'
    $expression = '1'; $var = 'foo'
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2014-08-29 06:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls