LPM: getopts *elp

Frank Price fprice at mis.net
Wed Aug 16 15:30:42 CDT 2000


> I don't know Getopt::Std, but I think I can get you what you want.
> You can scrap the comments later, of course.

[snip]

> # I assume the colon is syntax Getopt::Std uses
> getopts('s:', \%opt);
> my $sleep = 0;

The colon means that the s flag takes a mandatory argument.

> # "exists" prevents giving $opt{s} a value if it is undefined;
> # autovivifying can clobber you here!
> if exists ($opt{s}) {
> 
>     # This puts in a default value when "s" is a key, but its
>     # value is undef.
>     $opt{s} = $default_s unless defined($opt{s});

Works like a charm!  Thanks Ken...

-Frank.
-- 
Frank Price | fprice at mis.net | www.sxse.org/fprice/
GPG key: www.sxse.org/fprice/gpg.asc | E Pluribus Unix




More information about the Lexington-pm mailing list