line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Squatting::H; |
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
1165
|
use Clone; |
|
1
|
|
|
|
|
12630
|
|
|
1
|
|
|
|
|
1394
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $AUTOLOAD; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Squatting::H->new(\%attributes) -- constructor |
9
|
|
|
|
|
|
|
sub new { |
10
|
1
|
|
|
1
|
1
|
3
|
my ($class, $opts) = @_; |
11
|
1
|
|
50
|
|
|
5
|
$opts ||= {}; |
12
|
1
|
|
|
|
|
8
|
CORE::bless { %$opts } => $class; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Squatting::H->bless(\%attributes) -- like new() but directly bless $opts instead of making a shallow copy. |
16
|
|
|
|
|
|
|
sub bless { |
17
|
0
|
|
|
0
|
1
|
0
|
my ($class, $opts) = @_; |
18
|
0
|
|
0
|
|
|
0
|
$opts ||= {}; |
19
|
0
|
|
|
|
|
0
|
CORE::bless $opts => $class; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# $object->extend(\%attributes) -- extend keys and values of another hashref into $self |
23
|
|
|
|
|
|
|
sub extend { |
24
|
0
|
|
|
0
|
1
|
0
|
my ($self, $extend) = @_; |
25
|
0
|
|
|
|
|
0
|
for (keys %$extend) { |
26
|
0
|
|
|
|
|
0
|
$self->{$_} = $extend->{$_}; |
27
|
|
|
|
|
|
|
} |
28
|
0
|
|
|
|
|
0
|
$self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# $object->clone(\%attributes) -- copy constructor |
32
|
|
|
|
|
|
|
sub clone { |
33
|
3
|
|
|
3
|
1
|
1722
|
my ($self, $extend) = @_; |
34
|
3
|
|
|
|
|
115
|
my $clone = Clone::clone($self); |
35
|
3
|
50
|
|
|
|
16
|
$clone->extend($extend) if ($extend); |
36
|
3
|
|
|
|
|
9
|
$clone; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# $object->slots -- keys of underlying hashref of $object |
40
|
|
|
|
|
|
|
sub slots { |
41
|
0
|
|
|
0
|
1
|
0
|
keys %{$_[0]} |
|
0
|
|
|
|
|
0
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# $object->can($method) -- does the $object support this $method? |
45
|
|
|
|
|
|
|
sub can { |
46
|
14
|
50
|
|
14
|
1
|
1054
|
UNIVERSAL::can($_[0], $_[1]) || $_[0]->{$_[1]}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# $self->$method -- treat key values as methods |
50
|
|
|
|
|
|
|
sub AUTOLOAD { |
51
|
4
|
|
|
4
|
|
29
|
my ($self, @args) = @_; |
52
|
4
|
|
|
|
|
8
|
my $attr = $AUTOLOAD; |
53
|
4
|
|
|
|
|
18
|
$attr =~ s/.*://; |
54
|
4
|
100
|
|
|
|
17
|
if (ref($self->{$attr}) eq 'CODE') { |
55
|
3
|
|
|
|
|
13
|
$self->{$attr}->($self, @args) |
56
|
|
|
|
|
|
|
} else { |
57
|
1
|
50
|
|
|
|
3
|
if (@args) { |
58
|
0
|
|
|
|
|
0
|
$self->{$attr} = $args[0]; |
59
|
|
|
|
|
|
|
} else { |
60
|
1
|
|
|
|
|
8
|
$self->{$attr}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
0
|
|
|
sub DESTROY { } |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |