| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright (C) 2003-2007, G. Allen Morris III, all rights reserved |
|
2
|
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
38
|
use strict; |
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
5826
|
|
|
4
|
|
|
|
|
|
|
package |
|
5
|
|
|
|
|
|
|
Data::Tabular::Extra; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new |
|
8
|
|
|
|
|
|
|
{ |
|
9
|
418
|
|
|
418
|
1
|
9349
|
my $class = shift; |
|
10
|
418
|
|
|
|
|
1317
|
my $args = {@_}; |
|
11
|
418
|
|
|
|
|
1170
|
my $self = bless {}, $class; |
|
12
|
|
|
|
|
|
|
|
|
13
|
418
|
|
|
|
|
811
|
for my $arg (qw (row table)) { |
|
14
|
836
|
|
50
|
|
|
2630
|
$self->{$arg} = $args->{$arg} || die 'No ' . $arg; |
|
15
|
836
|
|
|
|
|
7115
|
delete $args->{$arg}; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
418
|
50
|
|
|
|
1792
|
die q|Unknown argumet(s): |. join(' ', keys(%$args)) if keys(%$args); |
|
18
|
|
|
|
|
|
|
|
|
19
|
418
|
50
|
|
|
|
1176
|
die unless $self->{row}; |
|
20
|
418
|
50
|
|
|
|
2166
|
die unless $self->{table}; |
|
21
|
|
|
|
|
|
|
|
|
22
|
418
|
|
|
|
|
7626
|
$self; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub get |
|
26
|
|
|
|
|
|
|
{ |
|
27
|
16
|
|
|
16
|
1
|
77
|
my $self = shift; |
|
28
|
|
|
|
|
|
|
|
|
29
|
16
|
100
|
|
|
|
28
|
if (wantarray) { |
|
30
|
4
|
|
|
|
|
9
|
map({$self->{row}->get_column($_)} @_); |
|
|
8
|
|
|
|
|
35
|
|
|
31
|
|
|
|
|
|
|
} else { |
|
32
|
12
|
50
|
|
|
|
30
|
carp("only one column allowed in scalar context.") if @_ > 1; |
|
33
|
12
|
|
|
|
|
46
|
$self->{row}->get_column(shift); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub sum |
|
38
|
|
|
|
|
|
|
{ |
|
39
|
33
|
|
|
33
|
1
|
126
|
my $self = shift; |
|
40
|
33
|
|
|
|
|
37
|
my $total = 0; |
|
41
|
|
|
|
|
|
|
|
|
42
|
33
|
|
|
|
|
52
|
for my $column (@_) { |
|
43
|
66
|
|
|
|
|
191
|
my $data = $self->{row}->get_column($column); |
|
44
|
66
|
50
|
|
|
|
161
|
if (ref($data) eq 'HASH') { |
|
45
|
0
|
|
|
|
|
0
|
die; |
|
46
|
0
|
|
|
|
|
0
|
$data = $data->{html}; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
66
|
|
|
|
|
160
|
$total += $data; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
33
|
|
|
|
|
842
|
require Data::Tabular::Type::Formula; |
|
53
|
|
|
|
|
|
|
|
|
54
|
33
|
|
|
|
|
142
|
Data::Tabular::Type::Formula->new( |
|
55
|
|
|
|
|
|
|
data => $total, |
|
56
|
|
|
|
|
|
|
columns => [ @_ ], |
|
57
|
|
|
|
|
|
|
type => 'sum', |
|
58
|
|
|
|
|
|
|
); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub average |
|
62
|
|
|
|
|
|
|
{ |
|
63
|
33
|
|
|
33
|
1
|
129
|
my $self = shift; |
|
64
|
33
|
|
|
|
|
45
|
my $count = scalar(@_); |
|
65
|
|
|
|
|
|
|
|
|
66
|
33
|
|
|
|
|
36
|
my $total = 0; |
|
67
|
|
|
|
|
|
|
|
|
68
|
33
|
|
|
|
|
56
|
for my $column (@_) { |
|
69
|
66
|
|
|
|
|
188
|
$total += $self->{row}->get_column($column); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
33
|
|
|
|
|
173
|
require Data::Tabular::Type::Formula; |
|
73
|
|
|
|
|
|
|
|
|
74
|
33
|
|
|
|
|
156
|
Data::Tabular::Type::Formula->new( |
|
75
|
|
|
|
|
|
|
data => $total / $count, |
|
76
|
|
|
|
|
|
|
columns => [ @_ ], |
|
77
|
|
|
|
|
|
|
type => 'average', |
|
78
|
|
|
|
|
|
|
); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub row_id |
|
82
|
|
|
|
|
|
|
{ |
|
83
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
$self->{row}{row_id}; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub _new_cell |
|
89
|
|
|
|
|
|
|
{ |
|
90
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
91
|
0
|
|
|
|
|
|
my $args = { @_ }; |
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
$args |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
|
97
|
|
|
|
|
|
|
__END__ |