line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::ExtractText::Extra; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
19039
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
41
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.001001'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
338
|
use parent 'HTML::ExtractText'; |
|
1
|
|
|
|
|
198
|
|
|
1
|
|
|
|
|
3
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
3
|
|
|
3
|
1
|
1016
|
my $class = shift; |
12
|
3
|
|
|
|
|
14
|
my $self = $class->SUPER::new( @_ ); |
13
|
3
|
|
|
|
|
173
|
$self->whitespace(1); |
14
|
3
|
|
|
|
|
5
|
$self->nbsp(1); |
15
|
3
|
|
|
|
|
6
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _extract { |
19
|
3
|
|
|
3
|
|
581
|
my ( $self, $dom, $selector, $what ) = @_; |
20
|
|
|
|
|
|
|
|
21
|
3
|
|
|
|
|
6
|
my $want = $what->{ $selector }; |
22
|
3
|
|
|
|
|
1
|
my $find = $want; |
23
|
|
|
|
|
|
|
|
24
|
3
|
100
|
|
|
|
8
|
if ( ref $want eq 'ARRAY' ) { |
25
|
2
|
|
|
|
|
4
|
$find = $want->[0]; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
3
|
|
|
4
|
|
8
|
my @results = $dom->find( $find )->map(sub{ $self->_process })->each; |
|
4
|
|
|
|
|
768
|
|
29
|
|
|
|
|
|
|
|
30
|
3
|
|
|
|
|
252
|
for ( @results ) { |
31
|
4
|
50
|
|
|
|
7
|
$self->nbsp and tr/\x{00A0}/ /; |
32
|
4
|
50
|
|
|
|
5
|
$self->whitespace and s/^\s+|\s+$//g; |
33
|
4
|
100
|
|
|
|
8
|
if ( ref $want eq 'ARRAY' ) { |
34
|
2
|
100
|
|
|
|
8
|
if ( ref $want->[1] eq 'Regexp' ) { |
|
|
50
|
|
|
|
|
|
35
|
1
|
|
|
|
|
6
|
s/$want->[1]//g; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
elsif ( ref $want->[1] eq 'CODE' ) { |
38
|
1
|
|
|
|
|
4
|
$_ = $want->[1]->( $_ ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
3
|
|
|
|
|
11
|
return @results; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub whitespace { |
47
|
8
|
|
|
8
|
1
|
9
|
my $self = shift; |
48
|
8
|
100
|
|
|
|
11
|
if ( @_ ) { $self->[0]->{WHITESPACE} = shift; } |
|
3
|
|
|
|
|
5
|
|
49
|
8
|
|
|
|
|
20
|
return $self->[0]->{WHITESPACE}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub nbsp { |
53
|
8
|
|
|
8
|
1
|
7
|
my $self = shift; |
54
|
8
|
100
|
|
|
|
14
|
if ( @_ ) { $self->[0]->{nbsp} = shift; } |
|
3
|
|
|
|
|
4
|
|
55
|
8
|
|
|
|
|
16
|
return $self->[0]->{nbsp}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
q| |
59
|
|
|
|
|
|
|
I called the janitor the other day to see what he could do about my |
60
|
|
|
|
|
|
|
dingy linoleum floor. He said he would have been happy to loan me a |
61
|
|
|
|
|
|
|
polisher, but that he hadn't the slightest idea what he had done with |
62
|
|
|
|
|
|
|
it. I told him not to worry about it--that as a programmer |
63
|
|
|
|
|
|
|
it wasn't the first time I had experienced a buffer |
64
|
|
|
|
|
|
|
allocation failure due to a memory error. |
65
|
|
|
|
|
|
|
|; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |