perldoc Sub Opt

English

.::SubOpt(3)   User Contributed Perl Documentation   .::SubOpt(3) 
 
 
NAME 
       SubOpt - MT subroutine option parser 
 
SYNOPSIS 
         use SubOpt; 
 
         &mt ("foo", -option=>"neat!", -file=>"fancy.txt", "oops"); 
 
         sub mt{ 
             opt::default(option => 'none', file => 'hoge.txt'); 
             # Set default values. This is optional. 
 
             my @args = opt::get(@_); 
             # Parse options. 
 
             my ($first, $last) = @args; 
 
             print "first: $first \n last: $last\n"; 
             print "option: ", opt::val("option"), "\n"; 
             print "file: ", opt::val("file"), "\n"; 
             # Option values are accessed via opt::val(). 
 
 
DESCRIPTION 
         SubOpt parses the arguments given to a subroutine in a similar 
         manner as GetOpt module. 
 
         Option specified in the form: -option=>"hoge" 
         inputs the value "hoge" with a key "option". 
         i.e. option with '-' is stored with the value pointed with '=>'. 
 
         opt::get(@_) parses the option arguments, stores the options in its 
         class, and returns the array of arguments that are not options. 
 
         opt::default(<option>=><value>) sets default values for the options. 
         i.e. if the option is not specified, the value set with this method 
         is used. This method is optional. 
 
         opt::val(<option>) returns the value of the given option. 
 
         Although it is not necessary to use the methods with "opt::", we 
         strongly recommend to do so to avoid confusion. 
 
 
AUTHOR 
         Kazuharu Gaou Arakawa, gaou@g-language.org 
 
 
SEE ALSO 
       perl(1). 
 
 
 
 
 
 
29/Aug/2001            perl 5.005, patch 03                     1 
 
 
 
 
 
.::SubOpt(3)   User Contributed Perl Documentation   .::SubOpt(3)