Scope-Guard

 view release on metacpan or  search on metacpan

lib/Scope/Guard.pm  view on Meta::CPAN

    bless [ 0, $handler ], ref $class || $class;
}

sub dismiss {
    my $self = shift;
    my $dismiss = @_ ? shift : 1;

    $self->[0] = $dismiss;
}

sub guard(&) { __PACKAGE__->new(shift) }
sub scope_guard($) { __PACKAGE__->new(shift) }

sub DESTROY {
    my $self = shift;
    my ($dismiss, $handler) = @$self;

    $handler->() unless ($dismiss);
}

1;



( run in 1.458 second using v1.01-cache-2.11-cpan-49f99fa48dc )