in reply to ARGV behaviour in getopts std

but why $#ARGV !=6 is true?
Because $#ARGV is 5, which you can prove by printing its value:
use warnings; use strict; use Data::Dumper; use Getopt::Std; print '$#ARGV=', $#ARGV, "\n"; print Dumper(\@ARGV); if ($#ARGV == -1 || $#ARGV !=6) { print "ARGV is now reduced to <".@ARGV."> members:\n";#prints ARGV + as 6 } __END__ $#ARGV=5 $VAR1 = [ '-b', 'opt_b', '-p', 'opt_p', '-c', 'opt_c' ]; ARGV is now reduced to <6> members:
@ARGV

Replies are listed 'Best First'.
Re^2: ARGV behaviour in getopts std
by perl_mystery (Beadle) on Dec 21, 2010 at 23:05 UTC

    What is the difference between $#ARGV and @ARGV?I can see @ARGV has members,but what is $#ARGV,what does it contain?why is the number five?is it always "1" less than @ARGV?

      You will find the answer if you follow the link that I provided in my original reply and read it. If there is something unclear in the documentation, please specify what you don't understand. Here it is again: @ARGV

        Cool thanks,couldnt see the link before

      'scalar @array' is the number of elements in @array (sometimes also referred to as the length of @array).

      $#array is the last index of @array. By default the first index in an array is 0, so when using the default settings $#array will be 'scalar @array - 1'.

      Elda Taluta; Sarks Sark; Ark Arks

    A reply falls below the community's threshold of quality. You may see it by logging in.