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 (Canon)
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?
[LanX]: Yeah option a doesn't go into history
[LanX]: probably I need to teach the app to restart after C-c Kill
[Corion]: LanX: Maybe have an infinite-loop cmd file? Much easier than trying to manage that from within Perl IMO
[Corion]: Alternatively, relaunch the application from cron (or a Windows cron) every minute
[LanX]: will try infinite loop ...
[Corion]: :START ... goto START
[LanX]: oh .bat you mean?
[LanX]: obscure cult ...
[Corion]: LanX: cmd.exe is just another way to launch Perl
[LanX]: I know its a cult... and I repent it every time

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2017-03-27 15:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.