in reply to parse out anchor text
It's untested.#! /usr/bin/perl use strict; use warnings; use HTML::Parser; my $string = qq~.:<script>text</script> .:<script>text34</script> <div + class="bbcode">sammler schrieb:</div><a href="http//url.tld">test</a +>~; my $p = HTML::Parser->new(); $p->handler(start => \&start_handler,"tagname,attr,self"); $p->parse($string); sub start_handler{ return if(shift ne 'a'); print shift->{href}; my $self = shift; my $text; $self->handler(text => sub{$text = shift;},"dtext"); $self->handler(end => sub{print $text,"\n\n" if(shift eq 'a')},"tagn +ame"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: parse out anchor text
by tsu (Novice) on Jan 11, 2005 at 20:15 UTC |