line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::TableParser::Grid; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
50277
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
59
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
55
|
|
5
|
2
|
|
|
2
|
|
9
|
use Carp; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
149
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
1658
|
use version; our $VERSION = qv('0.0.5'); |
|
2
|
|
|
|
|
4929
|
|
|
2
|
|
|
|
|
13
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
3172
|
use HTML::TableParser; |
|
2
|
|
|
|
|
26168
|
|
|
2
|
|
|
|
|
885
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
2
|
|
|
2
|
1
|
88
|
my($class, $table_html, $offset) = @_; |
13
|
2
|
|
100
|
|
|
8
|
$offset ||= 0; |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
|
|
9
|
my $udata = { |
16
|
|
|
|
|
|
|
row => 0, |
17
|
|
|
|
|
|
|
data => [], |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
|
|
9
|
my @request = ({ |
21
|
|
|
|
|
|
|
id => 1, # parse the first table |
22
|
|
|
|
|
|
|
row => \&_row, |
23
|
|
|
|
|
|
|
udata => $udata, |
24
|
|
|
|
|
|
|
}); |
25
|
|
|
|
|
|
|
|
26
|
2
|
50
|
|
|
|
17
|
HTML::TableParser->new(\@request, { Decode => 1, Trim => 1, Chomp => 1 }) |
27
|
|
|
|
|
|
|
->parse($table_html) or croak $@; |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
|
|
144
|
bless { |
30
|
|
|
|
|
|
|
data => $udata->{data}, |
31
|
|
|
|
|
|
|
offset => $offset, |
32
|
|
|
|
|
|
|
}, $class; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub cell { |
36
|
6
|
|
|
6
|
1
|
621
|
my($self, $row, $column) = @_; |
37
|
6
|
|
|
|
|
9
|
$column -= $self->{offset}; |
38
|
6
|
|
|
|
|
9
|
$row -= $self->{offset}; |
39
|
6
|
|
|
|
|
27
|
$self->{data}[$row][$column]; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub row { |
43
|
1
|
|
|
1
|
1
|
2
|
my($self, $row) = @_; |
44
|
1
|
|
|
|
|
3
|
$row -= $self->{offset}; |
45
|
1
|
|
|
|
|
2
|
@{ $self->{data}[$row] }; |
|
1
|
|
|
|
|
5
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub column { |
49
|
1
|
|
|
1
|
1
|
480
|
my($self, $column) = @_; |
50
|
1
|
|
|
|
|
2
|
my @results; |
51
|
1
|
|
|
|
|
2
|
for my $row (@{ $self->{data} }) { |
|
1
|
|
|
|
|
4
|
|
52
|
2
|
|
|
|
|
5
|
push @results, $row->[$column]; |
53
|
|
|
|
|
|
|
} |
54
|
1
|
|
|
|
|
3
|
@results; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub num_columns { |
58
|
1
|
|
|
1
|
1
|
397
|
my($self, $row) = @_; |
59
|
1
|
|
33
|
|
|
7
|
$row ||= $self->{offset}; |
60
|
1
|
|
|
|
|
2
|
scalar @{ $self->{data}[$row - $self->{offset}] }; |
|
1
|
|
|
|
|
5
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub num_rows { |
64
|
1
|
|
|
1
|
1
|
2
|
my($self) = @_; |
65
|
1
|
|
|
|
|
3
|
scalar @{ $self->{data} }; |
|
1
|
|
|
|
|
5
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _row { |
69
|
4
|
|
|
4
|
|
2472
|
my($id, $line, $cols, $udata) = @_; |
70
|
4
|
|
|
|
|
5
|
my $column = 0; |
71
|
4
|
|
|
|
|
5
|
$udata->{data}[$udata->{row}][$column++] = $_ for @{ $cols }; |
|
4
|
|
|
|
|
27
|
|
72
|
4
|
|
|
|
|
16
|
$udata->{row}++; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
__END__ |