NAME

Sub::ScopeFinalizer - execute a code on exiting scope. ja;Sub::ScopeFinalizer - スコープ終了時にコードを実行

VERSION

Version 0.02

SYNOPSIS

use Sub::ScopeFinalizer qw(scope_finalizer);

{
  my $anchor = scope_finalizer { print "put clean up code here.\n"; };
  print "running block.\n";
}

DESCRIPTION

Sub::ScopeFinalizer invoke BLOCK, triggered by leaving a scope. It is similar to destructor or finally clause. ja; Sub::ScopeFinalizer は, スコープを抜けるのに合わせて BLOCK の 実行を行います. これはデストラクタや例外機構での finally 節と 似ています.

EXPORT

This module exports one function, scope_finalizer. ja; このモジュールは関数を1つ, scope_finalizer をエクスポートします.

FUNCTION

scope_finalizer

$o = scope_finalizer BLOCK;
$o = scope_finalizer BLOCK { args =>[...] };

Create a finalizer object. This is shortcut to invoke Sub::ScopeFinalizer->new(...). ja; 後始末オブジェクトを生成します. これは Sub::ScopeFinalizer->new(...) と同じです.

BLOCK will be executed when object is destroyed. In other words, process just exits a scope which object is binded on. ja; BLOCK はオブジェクトが破棄されたときに実行されます. つまり, コードの実行がオブジェクトのバインドされている スコープを抜けたその時に実行されます.

Second argument is optional hashref. $opts->{args} can contain argument for BLOCK as ARRAYref. ja; 2番目の引数として任意でハッシュリファレンスを渡せます. $opts->{args} に BLOCK を実行するときの引数を配列のリファレンス として渡せれます.

If you only call this function without bind, BLOCK is executed immediately because object is destroyed as soon as return from function. Don't forget to bind. ja; もしこの関数の復帰値をバインドせず単に呼び出したときには, オブジェクトは関数から戻るとすぐに破棄されるため BLOCK も すぐに起動されてしまいます. バインドは忘れずに.

CONSTRUCTOR

$pkg->new(CODEref);

$pkg->new(CODEref, HASHref);

Create a finalizer object. You must bind it with variable on scope. ja; 後始末オブジェクトの生成. 復帰値をスコープ内の変数にバインドするのを忘れずに.

See "scope_finalizer". ja; 詳細は "scope_finalizer" を参照.

METHODS

$obj->raise();

$obj->raise();
$obj->raise({args=>[...]});

Invoke finalizer before it run automatically. This method disables default invokation on scope leaving. ja; 自動的に呼ばれるのより前に後始末コードを起動します. このメソッドを呼ぶとスコープを抜けたときの起動は無効に なります.

This method takes one argument as optional hashref. $opts->{args} can contain argument for BLOCK as ARRAYref. if $opts->{args} is passed, args parameter on constructor is ignored. ja; 引数として任意でハッシュリファレンスを渡せます. $opts->{args} に BLOCK を実行するときの引数を配列のリファレンス として渡せれます. $opts->{args} を渡したときはコンストラクタの args パラメータは無視されます.

$obj->disable();

$obj->disable();
$obj->disable($flag);

Turn off BLOCK invoking. If optional argument $flag is passwd and it is false, cancel disabling, that is, enable invoking. ja; BLOCK の起動を無効にします. 引数 $flag に偽を渡すと無効化を解除, つまり 呼び出しを再度有効にします.

AUTHOR

YAMASHINA Hio, <hio at cpan.org> ja; 山科 氷魚 (YAMASHINA Hio), <hio at cpan.org>

BUGS

Please report any bugs or feature requests to bug-sub-scopescope_finalizer at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sub-ScopeFinalizer. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. ja; バグや要望は bug-sub-scopescope_finalizer at rt.cpan.org 宛に 報告してください. 若しくは http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sub-ScopeFinalizer. にある web インターフェースからでもかまいません. そこから私に通知され, そして私が変更を行うことで報告頂いたバグの進捗を 自動的にあなたに伝えるでしょう.

SUPPORT

You can find documentation for this module with the perldoc command. ja; このモジュールのドキュメントは perldoc コマンドで見ることが出来ます.

perldoc Sub::ScopeFinalizer

You can also look for information at: ja; また, 以下の場所でも見ることが出来ます:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2006 YAMASHINA Hio, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. ja; このプログラムはフリーソフトウェアです。あなたは Perl と同じ ライセンスの 元で再配布及び変更を行うことが出来ます.

17 POD Errors

The following errors were encountered while parsing the POD:

Around line 5:

Deleting unknown formatting code J<>

Around line 23:

Deleting unknown formatting code J<>

Around line 33:

Deleting unknown formatting code J<>

Around line 45:

Deleting unknown formatting code J<>

Around line 52:

Deleting unknown formatting code J<>

Around line 60:

Deleting unknown formatting code J<>

Around line 68:

Deleting unknown formatting code J<>

Around line 83:

Deleting unknown formatting code J<>

Around line 90:

Deleting unknown formatting code J<>

Around line 102:

Deleting unknown formatting code J<>

Around line 110:

Deleting unknown formatting code J<>

Around line 126:

Deleting unknown formatting code J<>

Around line 137:

Deleting unknown formatting code J<>

Around line 144:

Deleting unknown formatting code J<>

Around line 161:

Deleting unknown formatting code J<>

Around line 168:

Deleting unknown formatting code J<>

Around line 199:

Deleting unknown formatting code J<>