in reply to problem with Getopt::Long
There are a couple of probs with the given code
#!/use/your/bin/perl -w use strict; unless (@ARGV) {&usage} use Getopt::Long; my %options; my $ret = GetOptions( "i" => \$options{i}, "o=s" => \$options{o}, "p=s" => \$options{p}, "h" => \$options{h} ); if ($ret eq "" || $options{'h'}) {&usage} if ($options{i}) { print "i is enabled\n"; } if ($options{o}) { print "o is enabled file is $options{o}\n"; } if ($options{p}) { print "p is enabled value is $options{p}\n"; } sub usage { print " \nCommand line options: -i interactive -o file give a file -h help -p value personal\n"; exit; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: problem with Getopt::Long
by Nkuvu (Priest) on Aug 20, 2004 at 10:07 UTC | |
by Random_Walk (Prior) on Aug 20, 2004 at 10:15 UTC | |
by Nkuvu (Priest) on Aug 20, 2004 at 10:23 UTC | |
by Aristotle (Chancellor) on Aug 20, 2004 at 11:22 UTC | |
by Nkuvu (Priest) on Aug 20, 2004 at 13:40 UTC | |
by Random_Walk (Prior) on Aug 20, 2004 at 10:30 UTC |