my $var=func($param) || 0; #### my ($x,$y); $x=$x+1; # throws warning $y+=1; # no warning #### # heres a functional way my @no_undefs=map{$_ || 0} @has_undefs; # or with a modifier !defined($array[$_]) and $array[$_]=0 foreach 0..$#array; # or more elegantly $array[$_]||=0 foreach 0..$#array; # or with a funky sub # might be slow or big lists though sub undefs2zero {$_[$_]||=0 foreach 0..$#_} undefs2zero(@array);