use warnings; use strict; use Getopt::Long; my $location; my $user_cfg; #Define argument types GetOptions('location=s' => \$location, 'cfg=s' => \$user_cfg); #Check if cfg option was specified if ($user_cfg) { #Replace any spaces found in a "quoted" filename #i.e. ("sample test" --> "sample-test") $user_cfg =~ s/\s+/-/g; } print "location = $location\n"; print "cfg File = $user_cfg\n"; __END__ $ ./my_script --cfg='my test 2.cfg' --location='fake location name' location = fake location name cfg File = my-test-2.cfg
is there some kind of global variable (like $?, $!, etc...) that holds that entire line just executed through the command line$0 stores the command name and @ARGV stores all the arguments. Getopt::Long parses @ARGV.
In reply to Re: Parsing Command Line Options
by toolic
in thread Parsing Command Line Options
by mmartin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |