line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Try::Chain; ## no critic (TidyCode)
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6633
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
5
|
1
|
|
|
1
|
|
367
|
use parent qw(Exporter);
|
|
1
|
|
|
|
|
205
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
437
|
use Try::Tiny qw(try catch finally);
|
|
1
|
|
|
|
|
1547
|
|
|
1
|
|
|
|
|
310
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.003';
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw( try catch finally try_chain $call_m $fetch_i $fetch_k );
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub try_chain (&;@) { ## no critic (SubroutinePrototypes)
|
13
|
0
|
|
|
0
|
1
|
|
my ( $chain_code, @more ) = @_;
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $check_code = sub {
|
16
|
|
|
|
|
|
|
## no critic (ComplexRegexes)
|
17
|
0
|
0
|
|
0
|
|
|
m{
|
18
|
|
|
|
|
|
|
\A \QCan't call method "\E .*? \Q" on an undefined value\E \b
|
19
|
|
|
|
|
|
|
| \A \QCan't locate object method "\E .*? \Q" via package\E \b
|
20
|
|
|
|
|
|
|
| \A \QCan't use an undefined value as a HASH reference\E \b
|
21
|
|
|
|
|
|
|
| \A \QCan't use an undefined value as an ARRAY reference\E \b
|
22
|
|
|
|
|
|
|
}xms
|
23
|
|
|
|
|
|
|
or die $_; ## no critic (RequireCarping)
|
24
|
|
|
|
|
|
|
## use critic (ComplexRegexes)
|
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
return ();
|
27
|
0
|
|
|
|
|
|
};
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
return @more
|
30
|
|
|
|
|
|
|
? try {
|
31
|
0
|
|
|
0
|
|
|
try { $chain_code->() } catch { $check_code->() };
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} @more
|
33
|
0
|
0
|
|
0
|
|
|
: try { $chain_code->() } catch { $check_code->() };
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
}
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
our $call_m = sub { ## no critic (PackageVars)
|
37
|
|
|
|
|
|
|
my ( $self, $method, @more ) = @_;
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return $self ? $self->$method(@more) : ();
|
40
|
|
|
|
|
|
|
};
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
our $fetch_i = sub { ## no critic (PackageVars)
|
43
|
|
|
|
|
|
|
my ( $array_ref, $index ) = @_;
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return $array_ref->[$index];
|
46
|
|
|
|
|
|
|
};
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
our $fetch_k = sub { ## no critic (PackageVars)
|
49
|
|
|
|
|
|
|
my ( $hash_ref, $key ) = @_;
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
return $hash_ref->{$key};
|
52
|
|
|
|
|
|
|
};
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# $Id$
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1;
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__
|