package X::_;
# 雛型
=head1
use Toolkit;
use Data::Dumper;
use Data::Compare;
sub New
{
my $self = {};
my($class, $arg) = @_;
### assert:$class
bless {}, $class;
}
雛型 †
Perlモジュールの雛型。
sub _Init
{
my $self = shift;
my($class, $arg1) = @_;
return undef;
}
=cut
sub Dump
{
my $self = shift;
### assert:Data::Compare(\@_, [])
Dumper($self);
}
package WikiEngine::_;
1;
use strict; use lib 'S:\Perl\_lib';
use Data::Dumper; use Data::Compare;
use Toolkit; # use Smart::Comments qw/#####/;
#use WikiEngine::Base; # [[WikiEngine/Base]];
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 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 $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/;
# アクセサーの宣言 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;