Help for this page

Select Code to Download


  1. or download this
    my $var=func($param) || 0;
    
  2. or download this
    my ($x,$y);
    $x=$x+1; # throws warning
    $y+=1;   # no warning
    
  3. or download this
    # heres a functional way
    my @no_undefs=map{$_ || 0} @has_undefs;
    ...
    # might be slow or big lists though
    sub undefs2zero {$_[$_]||=0 foreach 0..$#_} 
    undefs2zero(@array);