line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
6
|
|
|
6
|
|
803084
|
use strict; |
|
6
|
|
|
|
|
80
|
|
|
6
|
|
|
|
|
212
|
|
2
|
6
|
|
|
6
|
|
32
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
307
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# ABSTRACT: Use 'unknown' values instead of undef ones |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Unknown::Values; |
7
|
|
|
|
|
|
|
$Unknown::Values::VERSION = '0.101'; |
8
|
6
|
|
|
6
|
|
144
|
use 5.01000; |
|
6
|
|
|
|
|
20
|
|
9
|
6
|
|
|
6
|
|
2382
|
use Unknown::Values::Instance; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
196
|
|
10
|
6
|
|
|
6
|
|
2492
|
use Unknown::Values::Instance::Fatal; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
157
|
|
11
|
6
|
|
|
6
|
|
2393
|
use Unknown::Values::Instance::Object; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
149
|
|
12
|
6
|
|
|
6
|
|
33
|
use Carp (); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
105
|
|
13
|
|
|
|
|
|
|
|
14
|
6
|
|
|
6
|
|
26
|
use Scalar::Util 'blessed'; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
1053
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub import { |
17
|
8
|
|
|
8
|
|
3615
|
my $class = shift; |
18
|
8
|
|
|
|
|
45
|
my $caller = caller; |
19
|
8
|
|
|
|
|
180
|
my $unknown_class = 'Unknown::Values::Instance'; |
20
|
8
|
100
|
|
|
|
40
|
if (@_) { |
21
|
2
|
100
|
|
|
|
9
|
if ( ':FATAL' eq $_[0] ) { |
|
|
50
|
|
|
|
|
|
22
|
1
|
|
|
|
|
2
|
$unknown_class = 'Unknown::Values::Instance::Fatal'; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
elsif ( ':OBJECT' eq $_[0] ) { |
25
|
1
|
|
|
|
|
3
|
$unknown_class = 'Unknown::Values::Instance::Object'; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
else { |
28
|
0
|
|
|
|
|
0
|
Carp::croak("I don't know how to create an Unknown::Values object of type '$_[0]'"); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
8
|
|
|
|
|
40
|
my $unknown = $unknown_class->new; |
32
|
8
|
|
|
|
|
21
|
my $unknown_sub = "${caller}::unknown"; |
33
|
8
|
|
|
|
|
26
|
my $is_unknown_sub = "${caller}::is_unknown"; |
34
|
6
|
|
|
6
|
|
48
|
no strict 'refs'; |
|
6
|
|
|
|
|
20
|
|
|
6
|
|
|
|
|
1285
|
|
35
|
8
|
|
|
95
|
|
56
|
*$unknown_sub = sub {$unknown}; |
|
95
|
|
|
|
|
19854
|
|
36
|
8
|
|
|
|
|
6668
|
*$is_unknown_sub = \&is_unknown; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub is_unknown(_) { |
40
|
110
|
100
|
66
|
110
|
1
|
5669
|
defined $_[0] |
|
|
|
100
|
|
|
|
|
41
|
|
|
|
|
|
|
&& blessed( $_[0] ) |
42
|
|
|
|
|
|
|
&& ( |
43
|
|
|
|
|
|
|
# Unknown::Values::Instance::Object overrides isa() |
44
|
|
|
|
|
|
|
( 'Unknown::Values::Instance::Object' eq ref $_[0] ) || $_[0]->isa("Unknown::Values::Instance") |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |