Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl
- use v5.14;
- use warnings;
- package t {
- use Moo;
- with 'Moo::Getopt';
- has 'bool' => (is => 'rw');
- has 'str' => (is => 'rw');
- has 'array' => (
- is => 'rw',
- coerce => sub {
- my ($p) = @_;
- if (defined $p and ref $p ne 'ARRAY') {
- $p = [split /,/, $p];
- }
- $p;
- }
- );
- has 'z' => (is => 'rw');
- sub getopt {
- 'USAGE: %c %o',
- ['bool', 'bool test', {required => 1}],
- ['str=s', 'str test'],
- ['array=s', 'array test'],
- ['z=s', 'array params test'],
- }
- }
- my $t = t->new_with_options;
- say $t->bool;
- say join q{ }, @{$t->array};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement