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