line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Util::Ref; |
2
|
169
|
|
|
169
|
|
1090
|
use strict; |
|
169
|
|
|
|
|
354
|
|
|
169
|
|
|
|
|
4483
|
|
3
|
169
|
|
|
169
|
|
804
|
use warnings; |
|
169
|
|
|
|
|
337
|
|
|
169
|
|
|
|
|
6538
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000153'; |
6
|
|
|
|
|
|
|
|
7
|
169
|
|
|
169
|
|
985
|
use Scalar::Util qw/reftype blessed refaddr/; |
|
169
|
|
|
|
|
443
|
|
|
169
|
|
|
|
|
12651
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT_OK = qw/rtype render_ref/; |
10
|
169
|
|
|
169
|
|
1164
|
use base 'Exporter'; |
|
169
|
|
|
|
|
357
|
|
|
169
|
|
|
|
|
56022
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub rtype { |
13
|
26501
|
|
|
26501
|
1
|
37718
|
my ($thing) = @_; |
14
|
26501
|
100
|
|
|
|
42225
|
return '' unless defined $thing; |
15
|
|
|
|
|
|
|
|
16
|
26499
|
|
|
|
|
37781
|
my $rf = ref $thing; |
17
|
26499
|
|
|
|
|
45754
|
my $rt = reftype $thing; |
18
|
|
|
|
|
|
|
|
19
|
26499
|
100
|
66
|
|
|
83797
|
return '' unless $rf || $rt; |
20
|
6103
|
100
|
|
|
|
16533
|
return 'REGEXP' if $rf =~ m/Regex/i; |
21
|
5838
|
50
|
|
|
|
10527
|
return 'REGEXP' if $rt =~ m/Regex/i; |
22
|
5838
|
|
50
|
|
|
15068
|
return $rt || ''; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub render_ref { |
26
|
16912
|
|
|
16912
|
1
|
26110
|
my ($in) = @_; |
27
|
|
|
|
|
|
|
|
28
|
16912
|
100
|
|
|
|
29477
|
return 'undef' unless defined($in); |
29
|
|
|
|
|
|
|
|
30
|
16610
|
|
|
|
|
25944
|
my $type = rtype($in); |
31
|
16610
|
100
|
|
|
|
43468
|
return "$in" unless $type; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Look past overloading |
34
|
4883
|
|
100
|
|
|
14852
|
my $class = blessed($in) || ''; |
35
|
4883
|
|
|
|
|
18044
|
my $it = sprintf('0x%x', refaddr($in)); |
36
|
4883
|
|
|
|
|
9999
|
my $ref = "$type($it)"; |
37
|
|
|
|
|
|
|
|
38
|
4883
|
100
|
|
|
|
10830
|
return $ref unless $class; |
39
|
2826
|
|
|
|
|
7719
|
return "$class=$ref"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |