Created
May 13, 2014 10:11
-
-
Save hitode909/5e61b92f56c4d2c1bc4c to your computer and use it in GitHub Desktop.
メソッドが呼ばれたときに同名のフィールドがあったらもしかしてって言いながら死ぬやつ
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 Mosikasite { | |
sub new { | |
my ($class) = @_; | |
bless {}, $class; | |
} | |
sub AUTOLOAD { | |
my ($self) = @_; | |
my $method = (split '::', $AUTOLOAD)[-1]; | |
if (@_ == 1 && exists $self->{$method}) { | |
die "もしかして:->{$method}"; | |
} else { | |
die; | |
} | |
} | |
}; | |
my $m = Mosikasite->new; | |
$m->{hoge} = 1; | |
$m->hoge; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment