@ARGV: Command Line Arguments
Perl has a special array called @ARGV .
This is the list of arguments passed along with the script name on the command line. Run the following perl script as:
perl -w script.pl test
foreach (@ARGV) {
print "$_\n";
}
Example
ubuntu@server3:~/perl$ cat arg.pl
#!/usr/bin/perl
foreach (@ARGV) {
print "$_\n";
}
====================
ubuntu@server3:~/perl$ perl -w arg.pl this is a test file
this
is
a
test
file
ubuntu@server3:~/perl$
