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