If I do not explicitly want a specific initial value for a variable, I purposely leave it undefined so that I get a warning if I use it before I was planning to.
If I do not want an explicit initial value for a variable, I tend to set it explicitly to undef. It tends to pair up well with a latter test for definedness, and it also shows that I have considered that the variable containing an undefined value is actually, er, defined behaviour. Consider the snippet:
my $key = undef; for my $k( keys %h ) { $key = $k if $h{$k} eq 'foo'; } if( defined $key ) { # ... }
I find it makes it clearer to see that the variable starts out undefined and that the loop could set the variable to some value.
In reply to Re:x2 Mathematics skills
by grinder
in thread Mathematics skills
by cored
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |