Next | Program Repair Shop | 12 |
269 die $usage if ($#ARGV < 0);
The problem with this is that $#ARGV is one off from what the author intends
He wants to discuss the number of command-line arguments
$#ARGV is not the number of command-line arguments
It is the number of command-line arguments less one
Is the intention here to die if the number of argument is negative?
No, it's really to die if there are no arguments:
die $usage if (@ARGV == 0);
Say what you mean
And we can get rid of the unnecessary parentheses:
die $usage if @ARGV == 0;
Next | ![]() |
Copyright © 2006 M. J. Dominus |