Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- script.pl "string1" "string2"
- use Getopt::Long;
- my $data = "file.dat";
- my $length = 24;
- my $verbose;
- $result = GetOptions ("length=i" => $length, # numeric
- "file=s" => $data, # string
- "verbose" => $verbose); # flag
- $numArgs = $#ARGV + 1;
- print "thanks, you gave me $numArgs command-line arguments.n";
- foreach $argnum (0 .. $#ARGV) {
- print "$ARGV[$argnum]n";
- }
- foreach my $arg (@ARGV) {
- print $arg, "n";
- }
- while (my $line = <>) {
- process_line($line);
- }
- while (my $arg = shift) {
- print "Found argument $argn";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement