=head1
雛型 †
Perlモジュールの雛型。
=cut
package WikiEngine::_;
package WikiEngine::_;
use strict;
use lib 'S:\Perl\_lib';
use strict; use lib 'S:\Perl\_lib';
use Data::Dumper;
use Data::Compare;
use Data::Dumper; use Data::Compare;
use Toolkit;
# use Smart::Comments qw/#####/;
use Toolkit; # use Smart::Comments qw/#####/;
#use WikiEngine::Base; # WikiEngine/Base[?];
#use WikiEngine::Base; # [[WikiEngine/Base]];
our($VERSION, @ISA);
$VERSION = 0.01;
@ISA = qw(WikiEngine);
our($VERSION, @ISA); $VERSION = 0.01; @ISA = qw(WikiEngine);
sub New
{
my $self = {};
my($class, $arg) = @_;
$self->{attr} = 'value';
# 開発時アサーション
### assert:$self
# 運用中のみのアサーション
##### assert:$class
bless $self, $class;
}
sub New { my $self = {}; my($class, $arg) = @_; $self->{attr} = 'value'; # 開発時アサーション ### assert:$self # 運用中のみのアサーション ##### assert:$class bless $self, $class; }
sub Dump
{
my $self = shift;
### assert:Data::Compare(\@_, [])
Dumper($self);
}
sub Dump { my $self = shift; ### assert:Data::Compare(\@_, []) Dumper($self); }
sub MethodA
{
my $self = shift;
my($arg1) = @_;
# 致命的エラーのとき
open my $f, '>', 'data.file' or die $!;
close $f or die $!;
# (復帰できる)エラー別に対処するとき
try {
}
catch Error::_::Err1 with {
# 独自エラーの処理1
my $e = shift;
}
except {
# 独自エラーの処理2
my $e = shift;
my $hander = sub {
$e->{-object} = $self;
throw $e;
};
reutrn {
'Error::_::Err2' => $hander,
'Error::_::Err3' => $hander,
'Error::_::Err4' => $hander,
};
}
otherwise {
# その他のエラー処理
my $e = shift;
throw Error::Simple->new($e->{-text});
}
finally {
};
1;
}
sub MethodA { my $self = shift; my($arg1) = @_; # 致命的エラーのとき open my $f, '>', 'data.file' or die $!; close $f or die $!; # (復帰できる)エラー別に対処するとき try { } catch Error::_::Err1 with { # 独自エラーの処理1 my $e = shift; } except { # 独自エラーの処理2 my $e = shift; my $handler = sub { $e->{-object} = $self; throw $e; }; return { 'Error::_::Err2' => $handler, 'Error::_::Err3' => $handler, 'Error::_::Err4' => $handler, }; } otherwise { # その他のエラー処理 my $e = shift; throw Error::Simple->new($e->{-text}); } finally { }; 1; }
# このクラス以下の独自エラー定義
package Error::_::Err1;
use base qw/Error::Simple/;
# このクラス以下の独自エラー定義 package Error::_::Err1; use base qw/Error::Simple/;
1;
# アクセサーの宣言 use AutoloadAccessor; # use [[AutoloadAccessor]]; use subs qw{ Store_Id Fetch_Id }; sub AUTOLOAD { return if our $AUTOLOAD =~ /::DESTROY$/; die unless not $AUTOLOAD =~ /::_Recompose$/; _Recompose($_[0], $AUTOLOAD, @_[1 .. $#_]); }
1;