line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Data::Dumper::Again; |
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
99724
|
use strict; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
146
|
|
6
|
5
|
|
|
5
|
|
27
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
271
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# for docs, look for F |
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
5227
|
use Data::Dumper (); |
|
5
|
|
|
|
|
49928
|
|
|
5
|
|
|
|
|
149
|
|
13
|
5
|
|
|
5
|
|
40
|
use Carp qw(carp croak); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
340
|
|
14
|
|
|
|
|
|
|
|
15
|
5
|
|
|
5
|
|
30
|
use base qw(Class::Accessor); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
4441
|
|
16
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw(ddumper)); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# the instance variables |
19
|
|
|
|
|
|
|
# ddumper - the Data::Dumper inner object |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
22
|
5
|
|
|
5
|
1
|
2056
|
my $proto = shift; |
23
|
5
|
|
33
|
|
|
32
|
my $class = ref $proto || $proto; |
24
|
5
|
|
|
|
|
12
|
my $obj = bless {}, $class; |
25
|
5
|
|
|
|
|
21
|
return $obj->_init(@_); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _init { |
29
|
5
|
|
|
5
|
|
10
|
my $self = shift; |
30
|
5
|
|
|
|
|
14
|
my %args = @_; |
31
|
|
|
|
|
|
|
|
32
|
5
|
|
|
|
|
29
|
my $dumper = Data::Dumper->new([]); |
33
|
|
|
|
|
|
|
|
34
|
5
|
|
|
|
|
186
|
while (my ($k, $v) = each %args) { |
35
|
2
|
|
|
|
|
20
|
my $p = "\u$k"; # turn into a method name |
36
|
2
|
50
|
|
|
|
13
|
if ($dumper->can($p)) { |
37
|
|
|
|
|
|
|
#print "invoke $p($v)\n"; # XXX debug for devel |
38
|
2
|
|
|
|
|
9
|
$dumper->$p($v); |
39
|
|
|
|
|
|
|
} else { |
40
|
0
|
|
|
|
|
0
|
carp "unknown constructor parameter '$k'"; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
5
|
|
|
|
|
32
|
$self->ddumper($dumper); |
44
|
5
|
|
|
|
|
108
|
return $self; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub guts { |
48
|
2
|
|
|
2
|
1
|
1221
|
return shift->ddumper; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# $vname = $self->_varname($wantarray); |
52
|
|
|
|
|
|
|
sub _varname { |
53
|
5
|
|
|
5
|
|
12
|
my $self = shift; |
54
|
5
|
|
|
|
|
16
|
my $wantarray = shift; |
55
|
5
|
|
|
|
|
24
|
my $varname = $self->ddumper->Varname; |
56
|
5
|
100
|
|
|
|
132
|
return ( $wantarray ? '*' : '$' ) . $varname; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# $s = $self->_raw_dump(\@values, \@names); |
60
|
|
|
|
|
|
|
sub _raw_dump { |
61
|
6
|
|
|
6
|
|
14
|
my $self = shift; |
62
|
6
|
|
|
|
|
22
|
my $values_ref = shift; |
63
|
6
|
|
|
|
|
14
|
my $names_ref = shift; |
64
|
6
|
|
|
|
|
21
|
$self->ddumper->Reset; # forget previous invocations |
65
|
6
|
|
|
|
|
130
|
$self->ddumper->Values( $values_ref ); |
66
|
6
|
|
|
|
|
133
|
$self->ddumper->Names( $names_ref ); |
67
|
6
|
|
|
|
|
125
|
return $self->ddumper->Dump; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub dump { |
71
|
5
|
|
|
5
|
1
|
3892
|
my $self = shift; |
72
|
5
|
|
|
|
|
15
|
my $wantarray = @_ != 1; |
73
|
5
|
100
|
|
|
|
24
|
my @values = ( $wantarray ? \@_ : shift ); |
74
|
5
|
|
|
|
|
25
|
my @names = ( $self->_varname($wantarray) ); |
75
|
5
|
|
|
|
|
21
|
return $self->_raw_dump(\@values, \@names); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub dump_scalar { |
79
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
80
|
0
|
|
|
|
|
0
|
my @values = ( shift ); |
81
|
0
|
|
|
|
|
0
|
my @names = ( $self->_varname(0) ); # wantarray => 0 |
82
|
0
|
|
|
|
|
0
|
return $self->_raw_dump(\@values, \@names); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub dump_list { |
86
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
87
|
0
|
|
|
|
|
0
|
my @values = ( \@_ ); |
88
|
0
|
|
|
|
|
0
|
my @names = ( $self->_varname(1) ); # wantarray => 1 |
89
|
0
|
|
|
|
|
0
|
return $self->_raw_dump(\@values, \@names); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub dump_named { |
93
|
1
|
|
|
1
|
1
|
703
|
my $self = shift; |
94
|
1
|
|
|
|
|
2
|
my @pairs = @_; |
95
|
1
|
|
|
|
|
2
|
my (@names, @values); |
96
|
1
|
|
|
|
|
10
|
while (@pairs) { |
97
|
1
|
|
|
|
|
3
|
my ($n, $v) = splice @pairs, 0, 2; |
98
|
1
|
|
|
|
|
2
|
push @names, $n; |
99
|
1
|
|
|
|
|
4
|
push @values, $v; |
100
|
|
|
|
|
|
|
} |
101
|
1
|
|
|
|
|
5
|
return $self->_raw_dump(\@values, \@names); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# the following AUTOLOAD sub implements set_* |
105
|
|
|
|
|
|
|
# and get_* methods |
106
|
|
|
|
|
|
|
|
107
|
5
|
|
|
5
|
|
13644
|
use vars qw($AUTOLOAD); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
1291
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub AUTOLOAD { |
110
|
0
|
|
|
0
|
|
|
my $self = shift; |
111
|
0
|
|
|
|
|
|
my $method = $AUTOLOAD; |
112
|
0
|
|
|
|
|
|
$method =~ s/.*:://; |
113
|
0
|
0
|
|
|
|
|
if ($method =~ /[gs]et_(\w+)/) { |
114
|
0
|
|
|
|
|
|
my $prop = "\u$1"; |
115
|
0
|
0
|
|
|
|
|
if ($self->ddumper->can($prop)) { |
116
|
0
|
|
|
|
|
|
return $self->ddumper->$prop(@_); |
117
|
|
|
|
|
|
|
} else { |
118
|
0
|
|
|
|
|
|
croak "unknown getter/setter method '$method'"; # XXX |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} |
121
|
0
|
|
|
|
|
|
croak "unknown method '$method'"; # XXX |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# this avoids invoking AUTOLOAD on destruction |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
0
|
|
|
sub DESTROY {} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |
129
|
|
|
|
|
|
|
|