File Coverage

blib/lib/Protect/Unwind.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 21 23 91.3


line stmt bran cond sub pod time code
1             package Protect::Unwind;
2              
3 9     9   279228 use strict;
  9         20  
  9         534  
4              
5 9     9   18988 use Guard;
  9         44618  
  9         938  
6              
7             our $VERSION = '0.300';
8              
9 9     9   101 use base 'Exporter';
  9         20  
  9         2338  
10             our @EXPORT = qw(protect unwind);
11              
12              
13             sub protect (&;@) {
14 10     10 0 23 my ($protected, $unwinder) = @_;
15              
16             scope_guard {
17 10     10   4371 $unwinder->();
18 10         69 };
19              
20 10         33 return $protected->();
21             }
22              
23             sub unwind (&) {
24 10     10 0 7084 my ($unwinder) = @_;
25              
26 10         48 return $unwinder;
27             }
28              
29             1;
30              
31              
32              
33             __END__