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

OK. I am new to perl, and only really use it as a hobby. I was writing a (very short) program to output certain lines from files specified at the command line. I noticed that, unless I use @ARGV = reverse @ARGV;, I get lines from the files in the reverse order in which I specified (Does that make sense?). In other words:
>perl myfile.pl file1 file2

outputs in the form:
-----lines from file2-----
-----lines from file1-----
etc. Is this supposed to happen? I am using ActivePerl under Win32, if that makes any difference. Also, are such "pre-defined variables" (@ARGV, and the like) case-sensitive? My background is in such obsolescent languages as BASIC and Pascal, so I am not used to certain rules.

Replies are listed 'Best First'.
Re: Stupid @ARGV question
by suaveant (Parson) on Jun 22, 2001 at 19:09 UTC
    You should post some of your code...

    are you doing a pop @ARGV to get items, if so, that would explain it. In that case you should use shift instead.

                    - Ant

Re: Stupid @ARGV question
by runrig (Abbot) on Jun 22, 2001 at 19:19 UTC
    In addition to what everyone else said, if you use the '<>' operator, you may not even have to deal with @ARGV explicitly (and input should be processed in the order specified on the command line), though in that case you may want to know about '$ARGV' and/or the -n or -p command line parameters. See perldocs perlop, perlrun and perlvar.
Re: Stupid @ARGV question
by holygrail (Scribe) on Jun 22, 2001 at 18:59 UTC
    As far as I know in your case $ARGV[0] is 'file1', and $ARGV[1] is 'file2'. The output depends on your program though, of which you have not included any source...
    For the case-sensitivity: Perl variables are case sensitive, so @argv is something else than @ARGV...

    --HolyGrail
Re: Stupid @ARGV question
by Aighearach (Initiate) on Jun 22, 2001 at 19:11 UTC
    Post your code and we can help better :)

    Maybe you are processing @ARGV with pop instead of either shift or foreach(@ARGV){...}
    --
    Snazzy tagline here