Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re^6: Warnings on unused variables?by Animator (Hermit) |
on Oct 02, 2008 at 07:08 UTC ( [id://714965]=note: print w/replies, xml ) | Need Help?? |
Because it is easier for maintenance to name them from the beggining. Suppose you use my (undef, $d, undef, $f) = @_; and 2 months later you also need another variable. Then you need to go look to what code calls is then try to add the argument there - or find another way of passing it - and ultimetly find out it is already being passed as the 3th argument. A real live example is from a mod_perl framework that uses: my ($data, $p, $r, $dbh) = @_;.
While most of the code will never use $r and $dbh it is still useful to store them in a lexical since it is immposible to predict how the subroutine will grow and when it will need them. What you call an advantage I call a serious disadvantage for maintenance. If you later need $r for some reason you need to look up as which argument it is passed.
In Section
Seekers of Perl Wisdom
|
|