opts man page on Fedora

Man page or keyword search:  
man Server   31170 pages
apropos Keyword Search (all sections)
Output format
Fedora logo
[printable version]

opts(3)		      User Contributed Perl Documentation	       opts(3)

NAME
       opts - simple command line option parser

SYNOPSIS
	 # in script.pl
	 use opts;

	 opts my $foo => 'Int';

	 ./script.pl --foo=4 # $foo => 4
	 ./script.pl --foo 4 # $foo => 4
	 ./script.pl -f=4    # $foo => 4

	 # in script.pl
	 opts my $foo => { 'Int', required => 1 },
	      my $bar => 'Int';

	 ./script.pl --foo=3 --bar=4 # $foo => 3, $bar => 4
	 ./script.pl --foo=4	     # $foo => 4, $bar => undef
	 ./script.pl --bar=4	     # error!

	 # in script.pl
	 opts my $foo => {isa => 'Int', default => 3},

	 ./script.pl --foo=4	 # $foo => 4
	 ./script.pl		 # $foo => 3

	 # in script.pl
	 opts my $foo => { isa => 'Int', alias => 'x|bar' };

	 ./script.pl --foo=4 # $foo => 4
	 ./script.pl --bar=4 # $foo => 4
	 ./script.pl -f=4    # $foo => 4
	 ./script.pl -x=4    # $foo => 4

DESCRIPTION
       opts is DSL for command line option.

Options
	 isa
	    define option value type. see $opts::TYPE_CONSTRAINT.
	    if you need more type, see opts::coerce

	 required
	   define option value is required.

	 default
	   define options default value. If passed a coderef, it
	   will be executed if no value is provided on the command line.

	 alias
	   define option param's alias.

TYPES
       Str
       Int
       Num
       Bool
       ArrayRef
       HashRef
       Multiple
	   This subtype is based off of ArrayRef.  It will attempt to split
	   any values passed on the command line on a comma: that is,

	       [ "one", "two,three" ]

	   will become

	       [ "one", "two", "three" ].

opts::coerce
	 opts::coerce NewType => SrcType => generater;

	 ex)
	   opts::coerce DateTime => 'Str' => sub { DateTime->strptime("%Y-%m-%d", shift) };

	   opts my $date => 'DateTime';

	   $date->ymd; # => yyyy/mm/dd

AUTHOR
       Kan Fushihara <kan.fushihara at gmail.com>

THANKS TO
       Chris Weyl <http://search.cpan.org/~rsrchboy/>

SEE ALSO
       http://github.com/tokuhirom/p5-args
       <http://github.com/tokuhirom/p5-args>, Getopt::Long

LICENSE
       This library is free software; you can redistribute it and/or modify it
       under the same terms as Perl itself.

perl v5.14.1			  2010-10-20			       opts(3)
[top]

List of man pages available for Fedora

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net