line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Util::Underscore::References; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#ABSTRACT: Functions for introspecting and manipulating references |
4
|
|
|
|
|
|
|
|
5
|
12
|
|
|
12
|
|
72
|
use strict; |
|
12
|
|
|
|
|
28
|
|
|
12
|
|
|
|
|
300
|
|
6
|
12
|
|
|
12
|
|
76
|
use warnings; |
|
12
|
|
|
|
|
27
|
|
|
12
|
|
|
|
|
1018
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
## no critic (ProhibitMultiplePackages) |
10
|
|
|
|
|
|
|
package # hide from PAUSE |
11
|
|
|
|
|
|
|
_; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
## no critic (RequireArgUnpacking, RequireFinalReturn, ProhibitSubroutinePrototypes) |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub ref_addr(_) { |
16
|
8
|
|
|
8
|
|
1985
|
goto &Scalar::Util::refaddr; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub ref_type(_) { |
20
|
141
|
|
|
141
|
|
4510
|
goto &Scalar::Util::reftype; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
BEGIN { |
24
|
|
|
|
|
|
|
# perl 5.10 thinks reftype qr// eq 'SCALAR'. |
25
|
|
|
|
|
|
|
# This is bogus, we'll have to correct that. |
26
|
12
|
50
|
|
12
|
|
5465
|
if ($^V < 5.011) { |
27
|
12
|
|
|
12
|
|
83
|
no warnings 'redefine'; |
|
12
|
|
|
|
|
26
|
|
|
12
|
|
|
|
|
1003
|
|
28
|
|
|
|
|
|
|
*ref_type = sub (_) { |
29
|
0
|
|
|
|
|
0
|
my $type = &Scalar::Util::reftype; |
30
|
0
|
0
|
0
|
|
|
0
|
return 'REGEXP' |
|
|
|
0
|
|
|
|
|
31
|
|
|
|
|
|
|
if defined $type |
32
|
|
|
|
|
|
|
and $type eq 'SCALAR' |
33
|
|
|
|
|
|
|
and ref $_[0] eq 'Regexp'; |
34
|
0
|
|
|
|
|
0
|
return $type; |
35
|
0
|
|
|
|
|
0
|
}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub ref_weaken(_) { |
40
|
3
|
|
|
3
|
|
1618
|
goto &Scalar::Util::weaken; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub ref_unweaken(_) { |
44
|
2
|
|
|
2
|
|
9
|
goto &Scalar::Util::unweaken; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub ref_is_weak(_) { |
48
|
9
|
|
|
9
|
|
4453
|
goto &Scalar::Util::isweak; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub is_ref(_) { |
52
|
18
|
100
|
100
|
18
|
|
6101
|
defined($_[0]) |
53
|
|
|
|
|
|
|
&& defined ref_type $_[0] |
54
|
|
|
|
|
|
|
&& !defined blessed $_[0]; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub is_scalar_ref(_) { |
58
|
|
|
|
|
|
|
defined($_[0]) |
59
|
|
|
|
|
|
|
&& ( |
60
|
|
|
|
|
|
|
(defined blessed $_[0]) |
61
|
|
|
|
|
|
|
? overload::Method($_[0], q[${}]) |
62
|
13
|
100
|
|
13
|
|
6490
|
: do { |
|
|
100
|
|
|
|
|
|
63
|
9
|
|
100
|
|
|
21
|
my $type = ref_type $_[0] // q[]; |
64
|
9
|
100
|
|
|
|
67
|
$type eq 'SCALAR' || $type eq 'REF'; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub is_array_ref(_) { |
70
|
16
|
100
|
100
|
16
|
|
4756
|
defined($_[0]) |
|
|
100
|
|
|
|
|
|
71
|
|
|
|
|
|
|
&& ( |
72
|
|
|
|
|
|
|
(defined blessed $_[0]) |
73
|
|
|
|
|
|
|
? overload::Method($_[0], q[@{}]) |
74
|
|
|
|
|
|
|
: (ref_type $_[0] // q[]) eq 'ARRAY' |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub is_hash_ref(_) { |
79
|
12
|
100
|
100
|
12
|
|
4784
|
defined($_[0]) |
|
|
100
|
|
|
|
|
|
80
|
|
|
|
|
|
|
&& ( |
81
|
|
|
|
|
|
|
(defined blessed $_[0]) |
82
|
|
|
|
|
|
|
? overload::Method($_[0], q[%{}]) |
83
|
|
|
|
|
|
|
: (ref_type $_[0] // q[]) eq 'HASH' |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub is_code_ref(_) { |
88
|
12
|
100
|
100
|
12
|
|
4758
|
defined($_[0]) |
|
|
100
|
|
|
|
|
|
89
|
|
|
|
|
|
|
&& ( |
90
|
|
|
|
|
|
|
(defined blessed $_[0]) |
91
|
|
|
|
|
|
|
? overload::Method($_[0], q[&{}]) |
92
|
|
|
|
|
|
|
: (ref_type $_[0] // q[]) eq 'CODE' |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub is_glob_ref(_) { |
97
|
12
|
100
|
100
|
12
|
|
5056
|
defined($_[0]) |
|
|
100
|
|
|
|
|
|
98
|
|
|
|
|
|
|
&& ( |
99
|
|
|
|
|
|
|
(defined blessed $_[0]) |
100
|
|
|
|
|
|
|
? overload::Method($_[0], q[*{}]) |
101
|
|
|
|
|
|
|
: (ref_type $_[0] // q[]) eq 'GLOB' |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub is_regex(_) { |
106
|
12
|
100
|
66
|
12
|
|
4476
|
defined(blessed $_[0]) |
107
|
|
|
|
|
|
|
&& ('REGEXP' eq ref_type $_[0] |
108
|
|
|
|
|
|
|
|| overload::Method($_[0], q[qr])); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
__END__ |