line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: TableExtractor.pm,v 1.2 2002/06/11 15:52:25 simon Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package HTML::TableExtractor; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
15728
|
use HTML::Parser; |
|
1
|
|
|
|
|
5471
|
|
|
1
|
|
|
|
|
49
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
@ISA = qw(HTML::Parser); |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
419
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = 0.11; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# The tags we're interested in. |
16
|
|
|
|
|
|
|
my @tag_names = qw(table tr td th); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub start |
21
|
|
|
|
|
|
|
{ |
22
|
12
|
|
|
12
|
1
|
106
|
my ($self, $tag, $attr, $attrseq, $origtext) = @_; |
23
|
|
|
|
|
|
|
|
24
|
12
|
100
|
|
|
|
16
|
return unless grep { $_ eq lc($tag) } @tag_names; |
|
48
|
|
|
|
|
109
|
|
25
|
|
|
|
|
|
|
|
26
|
8
|
100
|
|
|
|
26
|
if (ref($self->{"${tag}_start_callback"}) eq 'CODE') { |
27
|
5
|
|
|
|
|
6
|
&{$self->{"${tag}_start_callback"}}($attr, $origtext); |
|
5
|
|
|
|
|
16
|
|
28
|
|
|
|
|
|
|
} |
29
|
8
|
100
|
|
|
|
64
|
if (ref($self->{"${tag}_callback"}) eq 'CODE') { |
30
|
4
|
|
|
|
|
6
|
&{$self->{"${tag}_callback"}}($attr, $origtext); |
|
4
|
|
|
|
|
13
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub end |
39
|
|
|
|
|
|
|
{ |
40
|
14
|
|
|
14
|
1
|
89
|
my ($self, $tag, $origtext) = @_; |
41
|
|
|
|
|
|
|
|
42
|
14
|
100
|
|
|
|
16
|
return unless grep { $_ eq lc($tag) } @tag_names; |
|
56
|
|
|
|
|
125
|
|
43
|
|
|
|
|
|
|
|
44
|
8
|
100
|
|
|
|
26
|
if (ref($self->{"${tag}_callback"}) eq 'CODE') { |
45
|
4
|
|
|
|
|
4
|
&{$self->{"${tag}_callback"}}($origtext); |
|
4
|
|
|
|
|
10
|
|
46
|
|
|
|
|
|
|
} |
47
|
8
|
100
|
|
|
|
40
|
if (ref($self->{"${tag}_end_callback"}) eq 'CODE') { |
48
|
4
|
|
|
|
|
5
|
&{$self->{"${tag}_end_callback"}}($origtext); |
|
4
|
|
|
|
|
11
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub parse |
55
|
|
|
|
|
|
|
{ |
56
|
2
|
|
|
2
|
1
|
297
|
my ($self, $data, @types) = @_; |
57
|
2
|
|
|
|
|
13
|
my %cbs = @types; |
58
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
13
|
for (@tag_names) { |
60
|
8
|
100
|
|
|
|
26
|
$self->{$_ . "_callback"} = $cbs{$_} if exists $cbs{$_}; |
61
|
8
|
100
|
|
|
|
31
|
$self->{$_ . "_start_callback"} = $cbs{"start_$_"} |
62
|
|
|
|
|
|
|
if exists $cbs{"start_$_"}; |
63
|
8
|
100
|
|
|
|
26
|
$self->{$_ . "_end_callback"} = $cbs{"end_$_"} |
64
|
|
|
|
|
|
|
if exists $cbs{"end_$_"}; |
65
|
|
|
|
|
|
|
} |
66
|
2
|
|
|
|
|
32
|
$self->SUPER::parse($data); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |