⭐ in reply to undef vs. $foo = 0
But which you want probably depends on what it is you want to do. For some applications, you'd set $bar=0 initially (or $bar='' for others), so that could be useful.
Using undef $sum would be a somewhat subtle error in this case.my $sum; # ... $sum = 0; $sum += $_ for @array; print "Sum is $sum\n";
Other times, you want undefinedness, and you undef things accordingly. Which is right to use depends on what is "right".
|
|---|