NAME
Scope::local_OnExit - an execute-at-scope-exit mechanism using local
SYNOPSIS
our $onExit;
use Scope::local_OnExit;
...
sub SomethingCritical{
local$OnExit=\&release_lock;
obtain_lock;
...
}
DESCRIPTION
This very short module provides a pure-perl mechanism for executing perl code at scope exit, at the time that the "old value" is returned to the tied variable.
PORTING FROM Scope::OnExit
Instead of
on_scope_exit { do_something($var) };
one would code
local$OnExit=sub{ do_something($var) };
EXPORT
the scalar package variable $OnExit
is tied into the package.
To tie a different variable than $OnExit
, use empty parentheses on the use
line to suppress import
and tie the variable of your selection.
HISTORY
- 0.00
-
initial draft written March 2010 and published on a blog and submitted to the module-authors mailing list for comment.
- 0.01
-
This version (April 2010) reflects comments received.
SEE ALSO
Scope::OnExit provides the same functionality but must be compiled.
AUTHOR
David Nicol davidnico@cpan.org
Please comment via rt.cpan.org
COPYRIGHT AND LICENSE
Copyright (C) 2010 by David Nicol / TipJar LLC
Released under the http://creativecommons.org/licenses/by/3.0/ Creative Commons Attribution 3.0 Unported License
Leaving this section in the documentation in your installed library is sufficient attribution.