in reply to command line option with- or without argument
Using a colon ":" instead of the equals sign indicates that the option value is optional. In this case, if no suitable value is supplied, string valued options get an empty string '' assigned, while + numeric options are set to 0.
use strict; use warnings; use Getopt::Long; my $foo; GetOptions ('foo:s', \$foo); print "foo: $foo\n" if defined($foo); print "Unprocessed by Getopt::Long\n" if $ARGV[0]; foreach (@ARGV) { print "$_\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: command line option with- or without argument
by Vasek (Acolyte) on Aug 29, 2009 at 14:01 UTC |