grewal7634 has asked for the wisdom of the Perl Monks concerning the following question:

I have a perl script containing line $input= $ARGV[0];What does $ARGV[0] stands for in this line?

Replies are listed 'Best First'.
Re: $ARGV[0] meaning
by Corion (Patriarch) on Aug 01, 2014 at 07:02 UTC
Re: $ARGV[0] meaning
by AppleFritter (Vicar) on Aug 01, 2014 at 09:32 UTC

    Howdy grewal, and welcome back again to the Monastery! Although all (Perl-related) questions are welcome in the Monastery, I'd like to submit that you could've saved yourself the trouble of having to post this one by using your favorite Internet search engine to search for "perl $ARGV[0]".

    The first hit for me is this page, which says (right near the top):

    Perl automatically provides an array called @ARGV, that holds all the values from the command line.

    And if that's not enough (say, because you're not familiar with Perl's use of sigils like @ and $), it also explicitely says this a little further down:

    If you expect a single value on the command line you can check what was it, or if it was provided at all by looking at $ARGV[0]. If you expect two variables you will also check $ARGV[1]

    You might've gotten different results for your search, but I'm sure you would've found something to answer this question very quickly.

    Just a tip for next time!

      I understand your position, but as someone who did just google perl ARGV, this was the first page to show up for me. So it's not so bad that they asked.
Re: $ARGV[0] meaning
by Anonymous Monk on Aug 01, 2014 at 07:25 UTC
Re: $ARGV[0] meaning
by sandy105 (Scribe) on Aug 01, 2014 at 09:10 UTC

    $argv[0] is the first argument passed to the program

    eg.

    perl script.pl "location_filetoopen"
      thanks for stating this clearly enough for a newb to get

        Except it's wrong. :P s/argv/ARGV/;

        moo@cow~>perl -le 'print $argv[0] || "NONE 4 U"' OHAI NONE 4 U moo@cow~>perl -le 'print $ARGV[0] || "NONE 4 U"' OHAI OHAI