App-Gitc

 view release on metacpan or  search on metacpan

lib/App/Gitc/Reversible.pm  view on Meta::CPAN

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 
 
sub 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 )