in reply to HTML::TokeParser Line numbers
Because HTML::TokeParser is a HTML::Parser, you can try to add handler-subs for start/end events with an argspec of 'line'.
Something like
This is completly untested and "just written" after a quick scan of the HTML-Parser documentation, but I hope it helps.use HTML::TokeParser; my $line; sub lineHandler { $line = $_[0]; } my $p = HTML::TokeParser->new($ARGV[0]); $p->handler(start => \&lineHandler, 'line'); $p->handler(end => \&lineHandler, 'line'); while (my $token = $p->get_token() ) { my @tag = @{$token}; if( $tag[0] eq 'S' || $tag[0] eq 'E' ){ print "$line: $tag[@tag-1]\n" ; } }
regards,
tomte
An intellectual is someone whose mind watches itself.
-- Albert Camus
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: HTML::TokeParser Line numbers
by jithoosin (Scribe) on Nov 24, 2005 at 14:58 UTC | |
by Tomte (Priest) on Nov 24, 2005 at 15:02 UTC |