Filter::Arguments - Configure and read your command line arguments from @ARGV.
SYNOPSIS
use Filter::Arguments;
my $solo : Argument(bool) = 1;
my $bool_default : Argument;
my ($a,$b,$c) : Arguments(bool);
my ($d,$e,$f) : Arguments(value);
my ($x,$y,$z) : Arguments(xbool);
my ($three,$four,$five) : Arguments(value) = (3,4,5);
my ($six,$seven,$eight) : Arguments(bool) = ('SIX','SEVEN','EIGHT');
my @result = (
$solo,
$bool_default,
$a, $b, $c,
$d, $e, $f,
$x, $y, $z,
$three, $four, $five,
$six, $seven, $eight,
);
print join ',', @result;
if invoked as: $ script.pl --solo --a --b --c --d A --e B --f C --x --y --z --six
will print:
0,,1,1,1,A,B,C,0,0,1,3,4,5,0,SEVEN,EIGHT
DESCRIPTION
Here is a simple way to configure and parse your command line arguments from @ARGV.
ARG TYPES
- bool (default)
-
This type of argument is either 1 or 0. If it is initialized to 1, then it will flip-flop to 0 if the arg is given.
- xbool
-
The 'x' as in XOR boolean. Only one of these booleans can be true. The flip-flop behavior also applies to these also. So you may initialize them however, but if one is set then the others are set to the opposite value of the one that is set.
- value
-
This type takes on the value of the next argument presented.
DEPENDENCIES
Template Filter::Simple
BUGS
The line numbers reported in errors/warnings etc. are not what they seem. As a work-around, you can use the comment line number trick after the last argument attribute like this:
26 ...
27 my $verbose : Argument(bool);
28 my $number : Argument(value);
29 # line 30
30 ...
AUTHOR
Dylan Doxey <dylan.doxey@gmail.com>
COPYRIGHT AND LICENSE
Copyright (C) 2009 by Dylan Doxey
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 189:
=pod directives shouldn't be over one line long! Ignoring all 2 lines of content