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

@ARGV should be a read_only thing for a user.
This raises several questions.
  1. What has the ability to write @ARGV to do with the problem?
  2. Why should it be read_only? Why isn't it read_only if it should?
  3. Who's the user in this case? The programmer? The person running the code?
  • Comment on Re^2: How to escape white space in command line arguments

Replies are listed 'Best First'.
Re^3: How to escape white space in command line arguments
by Marshall (Canon) on Apr 13, 2010 at 08:19 UTC
    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.

      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.

        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.