| 1 | package HTML::ExtractText::Extra; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 2 | our $VERSION = '1.001002'; # VERSION | |||||||||||||
| 7 | |||||||||||||||
| 8 | 2 | ▶ | use parent 'HTML::ExtractText'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | |||||||||||||||
| 10 | sub new { | ||||||||||||||
| 11 | 3 | ▶ | my $class = shift; | ||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 12 | 3 | my $self = $class->SUPER::new( @_ ); | |||||||||||||
| 13 | 3 | $self->whitespace(1); | |||||||||||||
| 14 | 3 | $self->nbsp(1); | |||||||||||||
| 15 | 3 | return $self; | |||||||||||||
| 16 | } | ||||||||||||||
| 17 | |||||||||||||||
| 18 | sub _extract { | ||||||||||||||
| 19 | 3 | ▶ | my ( $self, $dom, $selector, $what ) = @_; | ||||||||||||
|
Subroutine
_extract: called CC=8 SCAR=20.9
| |||||||||||||||
| 20 | |||||||||||||||
| 21 | 3 | my $want = $what->{ $selector }; | |||||||||||||
| 22 | 3 | my $find = $want; | |||||||||||||
| 23 | |||||||||||||||
| 24 | 3 | ▶ | if ( ref $want eq 'ARRAY' ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 25 | 2 | $find = $want->[0]; | |||||||||||||
| 26 | } | ||||||||||||||
| 27 | |||||||||||||||
| 28 | 3 | ▶ | my @results = $dom->find( $find )->map(sub{ $self->_process })->each; | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 29 | |||||||||||||||
| 30 | 3 | for ( @results ) { | |||||||||||||
| 31 | 4 | ▶ | $self->nbsp and tr/\x{00A0}/ /; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 32 | 4 | ▶ | $self->whitespace and s/^\s+|\s+$//g; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 33 | 4 | ▶ | if ( ref $want eq 'ARRAY' ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 34 | 2 | ▶ | if ( ref $want->[1] eq 'Regexp' ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 35 | 1 | s/$want->[1]//g; | |||||||||||||
| 36 | } | ||||||||||||||
| 37 | elsif ( ref $want->[1] eq 'CODE' ) { | ||||||||||||||
| 38 | 1 | $_ = $want->[1]->( $_ ); | |||||||||||||
| 39 | } | ||||||||||||||
| 40 | } | ||||||||||||||
| 41 | } | ||||||||||||||
| 42 | |||||||||||||||
| 43 | 3 | return @results; | |||||||||||||
| 44 | } | ||||||||||||||
| 45 | |||||||||||||||
| 46 | sub whitespace { | ||||||||||||||
| 47 | 8 | ▶ | my $self = shift; | ||||||||||||
|
Subroutine
whitespace: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||
| 48 | 8 | ▶ | if ( @_ ) { $self->[0]->{WHITESPACE} = shift; } | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 49 | 8 | return $self->[0]->{WHITESPACE}; | |||||||||||||
| 50 | } | ||||||||||||||
| 51 | |||||||||||||||
| 52 | sub nbsp { | ||||||||||||||
| 53 | 8 | ▶ | my $self = shift; | ||||||||||||
|
Subroutine
nbsp: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||
| 54 | 8 | ▶ | if ( @_ ) { $self->[0]->{nbsp} = shift; } | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 55 | 8 | return $self->[0]->{nbsp}; | |||||||||||||
| 56 | } | ||||||||||||||
| 57 | |||||||||||||||
| 58 | 2 | 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__ | ||||||||||||||