in reply to Re: Count the number of parameters
in thread Count the number of parameters

$nargs = $#ARGV + 1;

Don't do that. $#foo + 1 isn't necessarily equal to @foo, but that's not the most important reason for not using it. You shouldn't use it because it is not what you meant.

If you want the number of elements, GET the number of elements. If you want the last index, GET the last index. Don't get the last index if you need the number of elements and don't get the number of elements to calculate the last index.

In short: use @foo if you mean @foo, use $#foo if you mean $#foo. Don't use @foo - 1 or $#foo + 1.

Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }