nysus has asked for the wisdom of the Perl Monks concerning the following question:
sub start { my ($parser,$tag,$attr) = @_; $parser->{last_tag} = $tag; return unless $tag eq 'a'; $parser->{attr} = $attr->{href}; $parser->handler(text => \&extract, 'self,attr,dtext'); $parser->handler(end => \&end, 'self,tagname'); } sub end { my ($parser,$tag) = @_; undef $parser->{last_tag}; return unless $tag eq 'a'; $parser->handler(text => undef); $parser->handler(end => undef); } sub extract { my ($parser,$attr,$text) = @_; if ($parser->{last_tag} eq 'a') { if ($parser->{attr} && $text && $text !~ /^\s*$/) { $text =~ s/\n*//g; $parser->{attr} =~ s/\n*//g;; push @array, $text; push @array, $parser->{attr}; } } }
<font size=+1><b><A HREF="/dailyglobe2/142/metro/Plan_adopts_Romney_s_ +ideas_on_higher_education_restructuring+.shtml">Plan adopts Romney's +ideas on higher education restructuring</a></b></font><br>
$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop";
$nysus = $PM . $MCF;
Click here if you love Perl Monks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Having HTML::Parser problem
by pfaut (Priest) on May 23, 2003 at 01:30 UTC | |
by nysus (Parson) on May 23, 2003 at 01:47 UTC | |
|
Re: Having HTML::Parser problem
by hossman (Prior) on May 23, 2003 at 06:50 UTC | |
by hacker (Priest) on May 24, 2003 at 13:23 UTC | |
|
Re: Having HTML::Parser problem
by nysus (Parson) on May 23, 2003 at 01:28 UTC |