Help for this page

Select Code to Download


  1. or download this
    $a=1;$b=2;$c=3;$d=4;$f=5;$g=6;$h=7;
    $foo = $a? $b? $c : $d? $e : $f : $g : $h;
    ...
    __END__
    syntax error at C:\temp\ternary.pl line 2, near "$g :"
    Execution of C:\temp\ternary.pl aborted due to compilation errors.
    
  2. or download this
    $foo = $a ? $b ? $c : $d ? $e : $f : $g;
    
  3. or download this
    $foo = !$a ? $g : $b ? $c : $d ? $e : $f;
    
  4. or download this
    $foo = !$a ? $g
               : $b ? $c
                    : $d ? $e
                         : $f;
    
  5. or download this
    $foo = $a ? ($b ? $c 
                    : ($d ? $e 
                          : $f)) 
              : $g;