Here is an example to illustrate it a bit better.
if( $#ARGV == -1 ){
print "No arguments passed.\n";
} else if( $#ARGV == 0 ){
print "One argument passed.\n";
} else {
print $#ARGV +1 ."arguments passed.\n";
}
I like using "scalar @ARGV" as this represents number of elements in an array. $#ARGV, instead, is the index of last element in the array. This is why it is off by one. If $[ (this is a special variable that sets the starting index of Perl arrays.) was set to 1 and not 0 (the default), then $#ARGV would not be off by one for our purposes. I would not mess with $[ as it is a global. Changing may break a lot modules.
my $argument_count = scalar @ARGV;
if( $argument_count == 0 ){
print "No arguments passed.\n";
} else if( $argument_count == 1 ){
print "One argument passed.\n";
} else {
print "$argument_count arguments passed.\n";
}