Normal people count from 1. Computer Scientist count from 0. Perl developers count from -1?
WTF?
oz@server ~ $ test.pl test num of args 0 oz@server ~ $ test.pl test test num of args 1 0 test 1 test oz@server ~ $ test.pl num of args -1 No arguments! oz@server ~ $My Code, just in case I am totally wrong about this here, :
$ cat test.pl
#!/usr/local/bin/perl -w
print "num of args $#ARGV \n";
if ( $#ARGV > 0 ){
for ( my $i = 0 ; $i <= $#ARGV ; ++$i ) {
print "$i\n";
print "$ARGV[$i]\n";
}
}
if ( @ARGV > 0 )
{
print "Number of arguments: " . scalar @ARGV . "\n";
}
else
{
print "No arguments!\n";
}