Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: Surprised by Perl parse of ternary operator

by eyepopslikeamosquito (Canon)
on Dec 16, 2011 at 12:52 UTC ( #943938=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    config = ''
    fred = 42
    fred == 42 ? config = 'k1' : config = 'k2'
    print "config=#{config}\n"
    
  2. or download this
    <?php
    $config = '';
    ...
    $fred == 42 ? $config = 'k1' : $config = 'k2';
    echo "config=$config\n";
    ?>
    
  3. or download this
    #include <stdio.h>
    int main()
    ...
       printf("config=%d\n", config);
       return 0;
    }
    
  4. or download this
       fred == 42 ? (config = 1) : (config = 2);  // this works
       fred == 42 ?  config = 1  : (config = 2);  // also works
       fred == 42 ? (config = 1) : config = 2;    // syntax error
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2014-09-24 00:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (243 votes), past polls