#file: getopt.pl #desc: testing the GetOptions module #auth: Alexandros Labrinidis #date: Thu Sep 29 00:34:10 EDT 2005 #help: http://perldoc.perl.org/Getopt/Long.html use strict; use Getopt::Long; ## variable declarations my ($length, @data, $verbose, $result, $onedata); ## default values #@data = ("file.txt"); @data = (); $length = 24; $verbose = 0; ## read command-line arguments $result = GetOptions ("length=i" => \$length, # numeric "file|data=s" => \@data, # string "verbose" => \$verbose); # flag print <<"END_MSG"; length = $length verbose = $verbose ------------------ END_MSG foreach $onedata (@data) { print "$onedata "; } print "\n";