line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Try::Chain; ## no critic (TidyCode)
|
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
114392
|
use strict;
|
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
112
|
|
4
|
5
|
|
|
5
|
|
16
|
use warnings;
|
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
111
|
|
5
|
5
|
|
|
5
|
|
1875
|
use parent qw(Exporter);
|
|
5
|
|
|
|
|
1007
|
|
|
5
|
|
|
|
|
21
|
|
6
|
5
|
|
|
5
|
|
2173
|
use Try::Tiny qw(try catch finally);
|
|
5
|
|
|
|
|
7552
|
|
|
5
|
|
|
|
|
1971
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.005';
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw(
|
11
|
|
|
|
|
|
|
try catch finally
|
12
|
|
|
|
|
|
|
try_chain
|
13
|
|
|
|
|
|
|
$call_m $call_em
|
14
|
|
|
|
|
|
|
$fetch_i $fetch_ei
|
15
|
|
|
|
|
|
|
$fetch_k $fetch_ek
|
16
|
|
|
|
|
|
|
);
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub try_chain (&;@) { ## no critic (SubroutinePrototypes)
|
19
|
22
|
|
|
22
|
1
|
14484
|
my ( $chain_code, @more ) = @_;
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $check_code = sub {
|
22
|
|
|
|
|
|
|
## no critic (ComplexRegexes)
|
23
|
12
|
100
|
|
12
|
|
57
|
m{
|
24
|
|
|
|
|
|
|
\A \QCan't call method "\E .*? \Q" on an undefined value\E \b
|
25
|
|
|
|
|
|
|
| \A \QCan't locate object method "\E .*? \Q" via package\E \b
|
26
|
|
|
|
|
|
|
| \A \QCan't use an undefined value as a HASH reference\E \b
|
27
|
|
|
|
|
|
|
| \A \QCan't use an undefined value as an ARRAY reference\E \b
|
28
|
|
|
|
|
|
|
}xms
|
29
|
|
|
|
|
|
|
or die $_; ## no critic (RequireCarping)
|
30
|
|
|
|
|
|
|
## use critic (ComplexRegexes)
|
31
|
|
|
|
|
|
|
|
32
|
10
|
|
|
|
|
48
|
return ();
|
33
|
22
|
|
|
|
|
55
|
};
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
return @more
|
36
|
|
|
|
|
|
|
? try {
|
37
|
6
|
|
|
6
|
|
256
|
try { $chain_code->() } catch { $check_code->() };
|
|
6
|
|
|
|
|
329
|
|
|
4
|
|
|
|
|
55
|
|
38
|
|
|
|
|
|
|
} @more
|
39
|
22
|
100
|
|
8
|
|
97
|
: try { $chain_code->() } catch { $check_code->() };
|
|
16
|
|
|
|
|
1045
|
|
|
8
|
|
|
|
|
127
|
|
40
|
|
|
|
|
|
|
}
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
our $call_m = sub { ## no critic (PackageVars)
|
43
|
|
|
|
|
|
|
my ( $self, $method, @more ) = @_;
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return $self ? $self->$method(@more) : ();
|
46
|
|
|
|
|
|
|
};
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
our $call_em = sub { ## no critic (PackageVars)
|
49
|
|
|
|
|
|
|
my ( $self, $method, @more ) = @_;
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
return $self && $self->can($method) ? $self->$method(@more) : ();
|
52
|
|
|
|
|
|
|
};
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
our $fetch_i = sub { ## no critic (PackageVars)
|
55
|
|
|
|
|
|
|
my ( $array_ref, $index ) = @_;
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
return $array_ref->[$index];
|
58
|
|
|
|
|
|
|
};
|
59
|
|
|
|
|
|
|
our $fetch_ei = sub { ## no critic (PackageVars)
|
60
|
|
|
|
|
|
|
my ( $array_ref, $index ) = @_;
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return exists $array_ref->[$index] ? $array_ref->[$index] : undef;
|
63
|
|
|
|
|
|
|
};
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
our $fetch_k = sub { ## no critic (PackageVars)
|
66
|
|
|
|
|
|
|
my ( $hash_ref, $key ) = @_;
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
return $hash_ref->{$key};
|
69
|
|
|
|
|
|
|
};
|
70
|
|
|
|
|
|
|
our $fetch_ek = sub { ## no critic (PackageVars)
|
71
|
|
|
|
|
|
|
my ( $hash_ref, $key ) = @_;
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
return exists $hash_ref->{$key} ? $hash_ref->{$key} : undef;
|
74
|
|
|
|
|
|
|
};
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# $Id$
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1;
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__
|