If you want to literally know what it stands for, the answer is ARGument
Vector. In programming, vector is generally a synonim for array (especially for BASIC, FORTRAN and C folks).
The identifier name descends from C, with some differences:
- it's usually lowercase in C;
- it's called argv in C just by convention, it
could be any other name;
- it's a local (lexical, auto) variable in C, it belongs to the Main package in Perl;
- the first element, in the C incarnation, is the program name; Perl stores this value in $0;
- C needs another parameter, argc, to know how many values are stored in argv; in Perl you can evaluate an array in scalar context to see how many values it contains, or you can use $#array to get the last valid index of teh array itself.
-- TMTOWTDI
| [reply] [d/l] [select] |
I can't remember where I saw this -- I think it was an
old version of Damian's Perl 6 slides -- but I think
Larry may ditch the 'V' and make it 'ARGS'.
-- Frag.
| [reply] |
You must have overlooked something in perldoc perlvar. | [reply] |
Oh, I didn't check in perlvar, I was looking mostly in: perldata, perlsyn, and perlop ... my fault.
I apologize for a dumb question. But I am still glad I asked, due to it bothering me for not knowing what it meant.
Andy Summers
| [reply] |
@ARGV is a special variable in Perl that stores arguments, either from the command line when you first initiate the script. For example:
#!/usr/bin/perl -w
use strict;
my $length = @ARGV;
## If the number of arguments is less than two, it dies
## else it shifts them off of the array and into the
## variables
if($length<2){
die"Not enough arguements!\n";
}else{
my $arg1 = shift;
my $arg2 = shift;
}
UPDATE: Corrected variable name.
UPDATE 2: And as runrig reminded me, there is also a $ARGV variable which contains the filename of an open file when you call it like this: <>
TStanley
--------
There's an infinite number of monkeys outside who want to talk to us
about this script for Hamlet they've worked out -- Douglas Adams/Hitchhiker's Guide to the Galaxy
| [reply] [d/l] |
| [reply] |