Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: Ternary operators: a hinderance, not a help

by Anonymous Monk
on Aug 10, 2005 at 10:56 UTC ( [id://482563]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $number = $logical_test ? $value : 0;
    
  2. or download this
    my $number = $value;
       $number = 0 unless $logical_test;
    
  3. or download this
    my $number = 0;
       $number = $value if $logical_test;
    
  4. or download this
    my $number = $logical_test && $value;
    
  5. or download this
    my $number;
    if ($logical_test) {
    ...
    else {
        $number = 0;
    }
    
  6. or download this
    my $number;
    if ($logical_test) {$number = $value}
    else               {$number = 0}
    
  7. or download this
    my $number = do {if ($logical_test) {$value} else {0}};
    
  8. or download this
    my $number = $logical_test ? $value : 0;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-03-29 14:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found