Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: ternary operator

by tmharish (Friar)
on Jan 18, 2013 at 06:55 UTC ( #1013967=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $a1=2; $b1=10; ($a1 > $b1) ? ($int = ($a1/$b1)) : ($int = ($b1/$a1)); 
    +print $int;
    
  2. or download this
    $a1=2; $b1=10; $int = ($a1 > $b1) ? ($a1/$b1) : ($b1/$a1); print $int;
    
  3. or download this
    use strict   ;
    use warnings ;
    ...
    
    print $int;
    
  4. or download this
    my $int = ( defined( $a1 ) and defined( $b1 ) ) ? ( ( $a1 > $b1 ) ? ( 
    +$a1 / $b1 ) : ( $b1 / $a1 ) ) : die( '$a1 and $b1 need to be defined'
    + ) ;
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (12)
As of 2014-08-22 08:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (150 votes), past polls