App-Gitc
view release on metacpan or search on metacpan
lib/App/Gitc/Reversible.pm view on Meta::CPAN
222324252627282930313233343536373839404142sub
to_undo (&) {
my
(
$code
) =
@_
;
push
our
(
@undo_stack
),
$code
;
return
;
}
sub
reversibly(&) {
my
(
$code
) =
@_
;
local
$SIG
{INT} =
sub
{
die
"SIGINT\n"
};
local
$SIG
{TERM} =
sub
{
die
"SIGTERM\n"
};
local
our
(
@undo_stack
);
# to allow nested, reversible computations
my
$rc
=
eval
{
$code
->() };
if
(
my
$exception
= $@ ) {
our
$failure_warning
;
warn
$failure_warning
if
defined
$failure_warning
;
( run in 0.330 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )