• 追加された行はこの色です。
  • 削除された行はこの色です。
RIGHT:[[:t/コード]]

 package AutoloadAccessor;

 use base qw{Exporter};
 our @EXPORT = qw{_Recompose _Do};

 sub _Recompose
 {
 	my $self = shift;
 	my($autoload, @value) = @_;
 	my($method, $field) = $autoload =~ m/(=?Fetch|Store|Execute)_(\w+)/;
 	if (defined $method and defined $field and $self->can("${method}_${field}")){
 		return $self->_Do($method, $field, @value);
 	}
 	else {
 		die "Undefind method \"$autoload\".\n";
 	}
 }

 sub _Do
 {
 	my $self = shift;
 	my($method, $field, @value) = @_;
 	
 	if ($method eq 'Fetch'){
 		$self->{$field};
 	}
 	elsif ($method eq 'Store'){
 		$self->{$field} = $value[0];
 	}
 	elsif ($method eq 'Execute'){
 		do $self->{$field};
 	}
 	else {
 		die "Undefind method \"${method}_${field}\".\n";
 	}
 	# 戻値が変わってしまうので、これ以上コードを書けない。
 }

 1;

=DESCRIPTION
use subs qw{
Store_Id Fetch_Id
Store_Ethernal Fetch_Ethernal
Store_Owner Fetch_Owner
};

use AutoloadAccessor;

sub AUTOLOAD
{
return if our $AUTOLOAD =~ /::DESTROY$/;
die unless not $AUTOLOAD =~ /::_Recompose$/;

_Recompose($_[0], $AUTOLOAD, @_[1 .. $#_]);
}

=cut