Tue 21 August, 2012
Slides made for YAPC::Europe 2012
option 'verbose' => (is => 'ro', short => 'v', repeatable => 1);
Download demo1.pl
$ perl slides/2012/08/moox-options-slide3d-demo1.pl -h
USAGE: moox-options-slide3d-demo1.pl [-hv] [long options...]
-v --verbose no doc for verbose
-h --help show this help message
$ perl slides/2012/08/moox-options-slide3d-demo1.pl -v
I have a tiny voice.
$ perl slides/2012/08/moox-options-slide3d-demo1.pl -vv
I have a tiny voice.
Oh wait, I can speak lourder. Boo :)
$ perl slides/2012/08/moox-options-slide3d-demo1.pl -vvv
I have a tiny voice.
Oh wait, I can speak louder. Boo :)
You will regret this. Yahhhhhhhhhhh, I speak too much.
option 'ids' => (is => 'ro', format => 'i', repeatable => 1,
required => 1, autosplit => ',');
Download demo2.pl
$ perl slides/2012/08/moox-options-slide3d-demo2.pl --ids=1
$VAR1 = [ 1 ];
$ perl slides/2012/08/moox-options-slide3d-demo2.pl --ids=1 --ids=2
$VAR1 = [ 1, 2 ];
$ perl slides/2012/08/moox-options-slide3d-demo2.pl --ids=1 --ids=2 --ids=3,4
$VAR1 = [ 1, 2, 3, 4 ];
use MooX::Options flavour => [qw( pass_through )], protect_argv => 0;
option 'output' => (is => 'ro', format => 's', required => 1, short => 'o');
...
say Dumper \@ARGV;
Download demo3.pl
$ perl slides/2012/08/moox-options-slide3d-demo3.pl -o my.zip
Output : my.zip
$VAR1 = [];
$ perl slides/2012/08/moox-options-slide3d-demo3.pl -o my.zip a b c d
Output : my.zip
$VAR1 = [ 'a', 'b', 'c', 'd' ];
{package myOutputRole; use strict; use warnings;
use Moo::Role;
use MooX::Options;
option 'output' => (is => 'ro', format => 's', required => 1, short => 'o');
1;
}
{package myVerboseRole; use strict; use warnings;
use Moo::Role;
use MooX::Options;
option 'verbose' => (is => 'ro', short => 'v', repeatable => 1);
1;
}
{package myOpt; use strict; use warnings;
use Moo;
use MooX::Options flavour => [qw( pass_through )], protect_argv => 0;
with 'myOutputRole', 'myVerboseRole';
1;
}
Download demo4.pl
$ perl moox-options-slide3d-demo4.pl -o test.zip -vvv file1 file2 file3
Output : test.zip
Verbose: 3
$VAR1 = [ 'file1', 'file2', 'file3' ];
{package myOpt; use strict; use warnings;
use Moo;
use MooX::Options flavour => [qw( pass_through )]
, protect_argv => 0
, skip_options => [qw/verbose/];
with 'myOutputRole', 'myVerboseRole';
1;
}
Download demo5.pl
$ perl moox-options-slide3d-demo5.pl -o test.zip -vvv file1 file2 file3
Output : test.zip
Verbose: 0
$VAR1 = [ '-vvv', 'file1', 'file2', 'file3' ];
Tue 21 August, 2012
Slides made for YAPC::Europe 2012