CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [cjsmall] Is it possible to use '?' as an option to &Getopts()?: Edit Log



FishMonger
Veteran / Moderator

Jul 17, 2015, 6:19 AM


Views: 5139
Re: [cjsmall] Is it possible to use '?' as an option to &Getopts()?

Use a lexical hash instead of the global $opt_ vars.

Code
my %opts; 
getopt('?', \%opts);


Personally, I think the Getopt::Long module coupled with Pod::Usage would be a better choice than Getopt::Std.

Code
use Getopt::Long; 
use Pod::Usage;

my $man = 0;
my $help = 0;

GetOptions('help|?' => \$help, man => \$man) or pod2usage(2);
pod2usage(1) if $help;
pod2usage(-exitval => 0, -verbose => 2) if $man;

http://search.cpan.org/~jv/Getopt-Long-2.47/lib/Getopt/Long.pm#Documentation_and_help_texts


(This post was edited by FishMonger on Jul 17, 2015, 6:20 AM)


Edit Log:
Post edited by FishMonger (Veteran) on Jul 17, 2015, 6:20 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives