Re: scalar / hash problem in HTML::Parser
- From: tim.bowden@xxxxxxxxxxxxxx (Tim Bowden)
- Date: Tue, 26 Feb 2008 13:49:20 +0900
I need to find a way to get HTML::Parser return the text between the tag
caught by the start_h handler and the related closing tag. Could
someone please point me in the right direction?
Cut down code thus far:
#!/usr/bin/perl -wT
use strict;
use HTML::Parser;
my %choices;
my $file = 'test_snippet';
my $parser = HTML::Parser-> new(api_version => 3,
start_h => [\&start, "tagname, attr, "],
); # I think I need to add something after attr, to get
# what I want, but not sure what to add
sub start {
my ($tag, $attr, $tagged_text) = @_; # $tagged_text should get
# whatever we pass after attr in start_h
print "we got: $tag\t$attr\t$tagged_text\n";
for (keys %{$attr}){
my $value = (${$attr}{$_});
# do something with $tagged_text if we had it
}
}
$parser->parse_file($file) or die "couldn't parse file";
## end
Thanks,
Tim Bowden (fighting back against the stupid stick)
.
- Follow-Ups:
- Re: scalar / hash problem in HTML::Parser
- From: Jim Gibson
- Re: scalar / hash problem in HTML::Parser
- References:
- scalar / hash problem in HTML::Parser
- From: Tim Bowden
- scalar / hash problem in HTML::Parser
- Prev by Date: Re: Is this possible to override print() ?
- Next by Date: testing Non_SOAP webservices
- Previous by thread: Re: scalar / hash problem in HTML::Parser
- Next by thread: Re: scalar / hash problem in HTML::Parser
- Index(es):