Command line arguments: ARGV

Hashes can be useful when a script is called with parameters. But first the ARGV array has to be copied to a hash.

#
# copy an array to a hash
#
my %params = @ARGV;
#
# look for command line parameter
#
my $volts = $params{volts} || 0.1;

This piece of code could have been invoked by

> perl script.pl volts 0.2

Another example for parsing the command line options:

while( $_ = $ARGV[0], /^-/){
  shift;
  if( /^-D(.*)/){ $debug = $1;}
  if( /^-v/){ $verbose++;}
  ...
}