I prefer to never initialize a variable as empty. Why? It is the best way to find out if you are actually using the variable in your code. Quick sample,
use warnings; my $retval = 0; warn "Return Value $retval\n";
You have not done anything with this value, and nothing gets reported as being a problem. If you do this,
use warnings; my $retval; warn "Return Value $retval\n";
You are going to get an uninitialized value warning, you will probably be saying WTF? Until you look and realize the code that you wanted was this,
use warnings; my $retval; $retval = get_value_from_subroutine(); warn "Return Value $retval\n";
It also reduces the amount of code that you have, I admit it is small, but do it a couple of hundred times, you get the idea.
In reply to Re: Use of uninitialized variables?
by Herkum
in thread Use of uninitialized variables?
by Zadeh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |