Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: "Getoptions'" argument syntax

by mikfire (Deacon)
on Jun 15, 2001 at 20:08 UTC ( [id://88926]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to "Getoptions'" argument syntax

borris)cat getopt.pl #!usr/bin/perl -w use Getopt::Long; use strict; GetOptions( "refresh=i", \ (my $refresh = 10 ) ); print "refresh = $refresh\n"; borris)perl getopt.pl refresh = 10 borris)perl getopt.pl -refresh 5 refresh = 5
Quick experimentation suggests that it provides a default value for an optional parameter. Which is really quite neat, and seems to be completely undocumented.

mikfire

Replies are listed 'Best First'.
Re: Re: "Getoptions'" argument syntax
by wog (Curate) on Jun 15, 2001 at 20:15 UTC
    ... seems to be completely undocumented.

    Getopt::Long's documentation does document it, though not directly (emphasis added):

    The call to GetOptions() parses the command line arguments that are present in "@ARGV" and sets the option variable to the value "1" if the option did occur on the command line. Otherwise, the option variable is not touched.
    It's just a little leap from that that you can take advantage of having an option's variable set before its passed to GetOptions, which is what the odd code given does.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://88926]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.