line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: /mirror/perl/HTML-Parser-Stacked/trunk/lib/HTML/Parser/Stacked.pm 8903 2007-11-10T17:37:37.203788Z daisuke $ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Copyright (c) 2007 Daisuke Maki |
4
|
|
|
|
|
|
|
# All rights reserved. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package HTML::Parser::Stacked; |
7
|
2
|
|
|
2
|
|
23651
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
83
|
|
8
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
72
|
|
9
|
2
|
|
|
2
|
|
20
|
use base qw(HTML::Parser); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
2231
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.00001'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new |
13
|
|
|
|
|
|
|
{ |
14
|
1
|
|
|
1
|
1
|
16
|
my $class = shift; |
15
|
1
|
|
|
|
|
4
|
my %args = @_; |
16
|
1
|
|
|
|
|
3
|
my (%handlers, %pargs); |
17
|
1
|
|
|
|
|
7
|
while (my($name, $spec) = each %args) { |
18
|
1
|
|
|
|
|
8
|
$handlers{ ($name =~ /^(.+)_h$/)[0] } = $spec; |
19
|
1
|
|
|
|
|
9
|
$pargs{ $name } = [ \&_dispatch, "self,event,$spec->[1]" ]; |
20
|
|
|
|
|
|
|
} |
21
|
1
|
|
|
|
|
11
|
my $self = $class->SUPER::new(%pargs); |
22
|
1
|
|
|
|
|
82
|
$self->{stacked_parser}{handlers} = \%handlers; |
23
|
1
|
|
|
|
|
5
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _dispatch |
27
|
|
|
|
|
|
|
{ |
28
|
11
|
|
|
11
|
|
40335
|
my ($self, $event, @args) = @_; |
29
|
11
|
|
|
|
|
36
|
my $cb_list = $self->{stacked_parser}{handlers}{$event}->[0]; |
30
|
11
|
|
|
|
|
38
|
$_->(@args) for @$cb_list; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |