* アトリビュート生成 - has[#e94855b7]
* アトリビュート生成 (has)[#e94855b7]

hasを使う。

*** User.pm [#q43981cb]
 package 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.pl [#c15804a5]
 use 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;

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS