in reply to Re^2: How to escape white space in command line arguments
in thread How to escape white space in command line arguments

Well I just saw this from the OP:
@ARGV = ("C:/Program Files/Perl Express/sample.txt", "some hash");

@ARGV is a special Perl variable that contains the command line arguments. A similar thing exists in other languages. In 'C' you also get argc which is the count of the argv strings, e.g. int main(int argc, char **argv), but argc is redundant because argv is a null terminated array of pointers to strings and therefore calculating argc is trivial. Perl uses @ARGV for the purpose of passing command line args and the scalar value of @ARGV is what 'C' calls argc.

Nobody but the O/S should set @ARGV.

  • Comment on Re^3: How to escape white space in command line arguments

Replies are listed 'Best First'.
Re^4: How to escape white space in command line arguments
by JavaFan (Canon) on Apr 13, 2010 at 13:59 UTC
    Nobody but the O/S should set @ARGV.
    Oh, really? So, shift is broken? Getopt::Long is very naughty, and doesn't get Christmas presents?

    And the OS doesn't even populate @ARGV. It's perl that does that - and it's not always a full copy of argv.

    Besides, this is Perl. Perl will do whatever I want.

Re^4: How to escape white space in command line arguments
by Anonymous Monk on Apr 13, 2010 at 08:25 UTC
      Cute. This code uses a local variable for @ARGV. We should start a new thread if we are going to debate the proper uses and abuses of local variables. This thread doesn't need local. For future reading see.. local vars in Perl.
        This code uses a local variable for @ARGV

        Um no. It properly localizes @ARGV and then sets @ARGV. You say Nobody but the O/S should set @ARGV but you forgot this is perl.