in reply to What does 'ARGV' mean?

@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

Replies are listed 'Best First'.
Re: Re: What does 'ARGV' mean?
by davorg (Chancellor) on Aug 10, 2001 at 13:10 UTC