DelphiFAQ Home Search:
General :: Programming :: perl
General questions about perl.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Recommended links on this topic:
Featured Article

Reading command line arguments from perl

Question:

I am writing some command line tools to manipulate a large number of text files. How can I pass commandline arguments?

Answer:

The command line can be read with @ARGV

#!/usr/bin/perl
 
 $numArgs = $#ARGV + 1;
 print "$numArgs command-line arguments.\n";
 
 foreach $argnum (0 .. $#ARGV) {
    print "@ARGV[$argnum]\n";
 }

Generated 0:02:07 on Feb 21, 2018