in reply to Getopts and required args
Note that 'l=s' means that l must be specified with a value, otherwise, GetOptions() fails.use strict; use warnings; use Getopt::Long; use vars qw($opt_u $opt_h $opt_a $opt_l); &GetOptions('l=s','u','h','a') || exit 1; print "Option found: u\n" if ($opt_u); print "Option found: h\n" if ($opt_h); print "Option found: a\n" if ($opt_a); if ($opt_l) { print "Option found: l\n"; print " with value: $opt_l\n"; } else { print "You must specify -l\n"; exit 1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Getopts and required args
by husker (Chaplain) on Jun 22, 2000 at 20:34 UTC | |
by Shendal (Hermit) on Jun 22, 2000 at 21:26 UTC |