- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- ソース を表示
- Perl-Mouse/Moose へ行く。
Moose 基本
ゲッターの拡張
package Obj;
use Moose;
has n => (
is => 'rw',
isa => 'Int',
);
around 'n' => sub {
my $next = shift;
my $self = shift;
return $self->$next . '!' unless @_;
my $arg = shift;
return $self->$next($arg);
};
package main;
my $o = Obj->new;
$o->n(10);
print $o->n, "\n"; # 10!とビックリがつく
http://search.cpan.org/perldoc?Moose::Manual::FAQ#How_can_I_inflate/deflate_values_in_accessors?