yes, why not?

@ARGV is something perl make at disposal for you: if you know what are you doing you can modify at your will: inserting or shifting from it.

Rare items Perl gives you are bad to modify: some of the puncuation variables are a good example to be bad to modify. What the need to modify $. current line number for example? Or what you gain setting $^O the operating system label?

@ARGV and many other varibles you have at disposal are useful to modify. Getopt::Long make a lot of work on @ARGV even if principally shifting it.

But consider you want to write a simple program, possibly a oneliner, that glob files and unfortunately you are working in a user unfriendly OS that does not glob files on command line. You can use glob expanding @ARGV in a BEGIN block:

perl -lne "BEGIN { @ARGV =  map glob, @ARGV; print qq(considering ).scalar @ARGV.qq( files\n);} ....

Or you want to have the first file processed to be the comparing stone and the following ones searched just for lines present in the first one:

perl -lne "%ln;BEGIN{open $f,shift;map{chomp;$ln{$_}++}<$f>}print qq($ +ARGV line\t$.\t[$_]) if exists $ln{$_};close ARGV if eof" dog.txt cat.txt other.txt

Or, if you have enough hubrys, want to evaluate some line number range popped from @ARGV while printing just some line of a file:

perl -E    "say+(0,<>)[eval pop]"                          linenumber.txt 1,3..5

So, imho, modify @ARGV if you need to!

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

In reply to Re^3: trying to read files in @ARGV but getting GLOB error! :( by Discipulus
in thread trying to read files in @ARGV but getting GLOB error! :( by fasoli

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.