Created
September 8, 2010 13:38
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Person; | |
use Moose; | |
with 'MooseX::Getopt'; | |
has 'id' => (is => 'rw', isa => 'Int'); | |
has 'name' => (is => 'rw', isa => 'Str'); #We'll get it from the id in a database | |
1; | |
my $p = Person->new_with_options(id=>1); | |
print $p->dump; | |
__DATA__ | |
run with: perl ./Person.pm | |
output: | |
$VAR1 = bless( { | |
'ARGV' => [], | |
'id' => 1, | |
'extra_argv' => [] | |
}, 'Person' ); | |
run with: perl ./Person.pm --id=3 | |
output: | |
$VAR1 = bless( { | |
'ARGV' => [ | |
'--id=3' | |
], | |
'id' => 3, | |
'extra_argv' => [] | |
}, 'Person' ); | |
run with: perl ./Person.pm --idd=3 | |
output: | |
STDERR: | |
Unknown option: idda | |
usage: Person.pm [long options...] | |
--id | |
--name | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment