アトリビュート生成 (has)hasを使う。 User.pmpackage User; use Mouse; use URI; has 'name' => ( is => 'rw', isa => 'Str' ); has 'age' => ( is => 'rw', isa => 'Int' ); has 'uri' => ( is => 'rw', isa => 'URI' ); __PACKAGE__->meta->make_immutable(); 1; main.pluse User; use URI; my $user = User->new( name => 'taro', age => 10, uri => URI->new('http://example.com/') ); say $user->name; say $user->age; say $user->uri; |
|