Perldoc Search: "@ARGV" perl-5.20.1

search official POD

17 PODs, 53 LINEs found.
803 :         An "eof" without an argument uses the last file read. Using "eof()" with empty parentheses is different. It refers to the pseudo file formed from the files listed on the command line and accessed via the "<>" operator. Since "<>" isn't explicitly opened, as a normal filehandle is, an "eof()" before "<>" has been used will cause @ARGV to be examined to determine if input is available. Similarly, an "eof()" after "<>" has returned end-of-file will assume you are processing another @ARGV list, and if you haven't set @ARGV, will read input from "STDIN"; see "I/O Operators" in perlop.
929 :             exec '/bin/echo', 'Your arguments are: ', @ARGV;
1969 :             foreach $file (@ARGV) {
2614 :         Returns the undefined value if the array is empty, although this may also happen at other times. If ARRAY is omitted, pops the @ARGV array in the main program, but the @_ array in subroutines, just like "shift".
2796 :         Note that you have can't handle "readline" errors that way with the "ARGV" filehandle. In that case, you have to open each element of @ARGV yourself since "eof" handles "ARGV" differently.
2798 :             foreach my $arg (@ARGV) {
3043 :         Resetting "A-Z" is not recommended because you'll wipe out your @ARGV and @INC arrays and your %ENV hash. Resets only package variables; lexical variables are unaffected, but they clean themselves up on scope exit anyway, so you'll probably want to use them instead. See "my".
3268 :         Shifts the first value of the array off and returns it, shortening the array by 1 and moving everything down. If there are no elements in the array, returns the undefined value. If ARRAY is omitted, shifts the @_ array within the lexical scope of subroutines and formats, and the @ARGV array outside a subroutine and also within the lexical scopes established by the "eval STRING", "BEGIN {}", "INIT {}", "CHECK {}", "UNITCHECK {}", and "END {}" constructs.
4063 :             @ARGV = @files;
4486 :             unshift(@ARGV, '-e') unless $ARGV[0] =~ /^-/;
4569 :             utime $atime, $mtime, @ARGV;
4573 :             for $file (@ARGV) {
138 :           exec($SELF, @ARGV)        || die "$0: couldn't restart: $!";
145 :           print "ARGV: @ARGV\n";
259 :     If one can be sure that a particular program is a Perl script expecting filenames in @ARGV, the clever programmer can write something like this:
760 :         foreach $host (@ARGV) {
929 :         unless (@ARGV > 1) { die "usage: $0 host url ..." }
930 :         $host = shift(@ARGV);
933 :         for my $document (@ARGV) {
978 :         unless (@ARGV == 2) { die "usage: $0 host port" }
979 :         ($host, $port) = @ARGV;
1109 :         for $host (@ARGV) {
1698 :     The null filehandle <> is special: it can be used to emulate the behavior of sed and awk, and any other Unix filter program that takes a list of filenames, doing the same to each line of input from all of them. Input from <> comes either from standard input, or from each file listed on the command line. Here's how it works: the first time <> is evaluated, the @ARGV array is checked, and if it is empty, $ARGV[0] is set to "-", which when opened gives you standard input. The @ARGV array is then processed as a list of filenames. The loop
1706 :         unshift(@ARGV, '-') unless @ARGV;
1714 :     except that it isn't so cumbersome to say, and will actually work. It really does shift the @ARGV array and put the current filename into the $ARGV variable. It also uses filehandle *ARGV* internally. <> is just a synonym for <ARGV>, which is magical. (The pseudo code above doesn't work because it treats <ARGV> as non-magical.)
1722 :     and call it with "perl 'rm -rfv *|'", it actually opens a pipe, executes the "rm" command and reads "rm"'s output from that pipe. If you want all items in @ARGV to be interpreted as file names, you can use the module "ARGV::readonly" from CPAN.
1724 :     You can modify @ARGV before the first <> as long as the array ends up containing the list of filenames you really want. Line numbers ($.) continue as though the input were one big happy file. See the example in "eof" in perlfunc for how to reset line numbers on each file.
1726 :     If you want to set @ARGV to your own list of files, go right ahead. This sets @ARGV to all plain text files if no @ARGV was given:
1728 :         @ARGV = grep { -f && -T } glob('*') unless @ARGV;
1732 :         @ARGV = map { /\.(gz|Z)$/ ? "gzip -dc < $_ |" : $_ } @ARGV;
1748 :     The <> symbol will return "undef" for end-of-file only once. If you call it again after this, it will assume you are processing another @ARGV list, and if you haven't set @ARGV, will read input from STDIN.
55 :               ARGC      scalar @ARGV (compare with $#ARGV)
166 :     *   The arguments are available via @ARGV, not $1, $2, etc.
181 :     *   People have a hard time remembering that some functions default to $_, or @ARGV, or whatever, but that others which you might expect to do not.
87 :         $ perl -e "print join(' ',@ARGV)" perl.*
92 :         $ perl -e "print join(' ',@ARGV)" """perl.*"""
149 :              A    32   the @ARGV elements are expected to be strings encoded
411 :     -s   enables rudimentary switch parsing for switches on the command line after the program name but before any filename arguments (or before an argument of --). Any switch found there is removed from @ARGV and sets the corresponding variable in the Perl program. The following program prints "1" if the program is invoked with a -xyz switch, and "abc" if it is invoked with -xyz=abc.
690 :     @ARGV   The array @ARGV contains the command-line arguments intended for the script. $#ARGV is generally the number of arguments minus one, because $ARGV[0] is the first argument, *not* the program's command name itself. See "$0" for the command name.
692 :     ARGV    The special filehandle that iterates over command-line filenames in @ARGV. Usually written as the null filehandle in the angle operator "<>". Note that currently "ARGV" only has its magical effect within the "<>" operator; elsewhere it is just a plain filehandle corresponding to the last file opened by "<>". In particular, passing "\*ARGV" as a parameter to a function that expects a filehandle may not cause your function to automatically read the contents of all the files in @ARGV.
296 :         for (@ARGV) {
642 :     The same problems ensue if you enable automatic UTF-8-ification of your standard file handles, default "open()" layer, and @ARGV on non-ISO8859-1, non-UTF-8 locales (by using either the -C command line switch or the "PERL_UNICODE" environment variable; see perlrun). Things are read in as UTF-8, which would normally imply a Unicode interpretation, but the presence of a locale causes them to be interpreted in that locale instead. For example, a 0xD7 code point in the Unicode input, which should mean the multiplication sign, won't be interpreted by Perl that way under the Greek locale. This is not a problem *provided* you make certain that all locales will always and only be either an ISO8859-1, or, if you don't have a deficient C library, a UTF-8 locale.
750 :         The global variables, like @ARGV or the punctuation variables, must be "local"ized with "local()". This block reads in /etc/motd, and splits it up into chunks separated by lines of equal signs, which are placed in @Fields.
753 :                 local @ARGV = ("/etc/motd");
234 :         $temp = join($", @ARGV);
237 :         system "echo @ARGV";
26 :             $arrayref  = \@ARGV;
179 :         die "usage mkrot13 filename\n" unless @ARGV;
148 :         There are a couple of special arrays too, such as @ARGV (the command line arguments to your script) and @_ (the arguments passed to a subroutine). These are documented in perlvar.
680 :     While Perl does have extensive ways to input and output in Unicode, and a few other "entry points" like the @ARGV array (which can sometimes be interpreted as UTF-8), there are still many places where Unicode (in some encoding or another) could be given as arguments or received as results, or both, but it is not.
17 :     As you see from those examples, "STDOUT" and "STDERR" are output handles, and "STDIN" and "ARGV" are input handles. They are in all capital letters because they are reserved to Perl, much like the @ARGV array and the %ENV hash are. Their external associations were set up by your shell.
62 :     You can enable automatic UTF-8-ification of your standard file handles, default "open()" layer, and @ARGV by using either the "-C" command line switch or the "PERL_UNICODE" environment variable, see perlrun for the documentation of the "-C" switch.
69 :        9 mtime                9 bitmask     @ARGV command line args
<< Back to Perldoc Search