HTML::PullParser error

  • Thread starter Randall S Benson
  • Start date
R

Randall S Benson

I am currently writing a benchmark tester for a web application.
I send the first command, then gather the results, on the third time
around I parse the results to build the arguments for the next command.

sub parseQuerySchedule()
{
my $wcontent = shift;
my @FORM_TAGS = qw(input);
my $names;
my $string = "";
my $found = 0;

if (!defined($wcontent)){return $string;}
# print "$wcontent\n";

my $p = HTML::pullParser->new(
$wcontent,
start => 'tag, attr',
end => 'tag',
text => '@{text}',
report_tags => \@FORM_TAGS,
)
|| die "$!";

while ( defined( my $t = $p->get_token ) )
{
if ( $t->[0] eq "input" )
{
$names = $t->[1];

# print "the keys... ", sort keys %$names, "...\n";
if ( defined( $names ) )
{
if ( $names->{'name'} eq 'storeTrainInfo' )
{
$found = 1;
$string = buildShopAvailString( $names->{'onclick'} );
return $string;
}
}

}
}
if ( !$found )
{
lock $NOTRAINS;
$NOTRAINS = 1;

}
}

This works most of the times, but randomly the following error happens:

Odd number of elements in hash assignment at /usr/lib/perl5/HTML/PullParser.pm line 14.
thread failed to start: Info not collected for any events at TWEtest.pl line 552
Use of uninitialized value in numeric gt (>) at TWEtest.pl line 151.
Use of uninitialized value in addition (+) at TWEtest.pl line 153.
Use of uninitialized value in addition (+) at TWEtest.pl line 155.
Use of uninitialized value in addition (+) at TWEtest.pl line 156.

Line 552 is the creation of the PullParser.

I thought it was incomplete HTML that was causing the problem, but dumping
it showed that the HTML was complete.

Anyone encounter this error, and if so, is there a solution?

perl version:
This is perl, v5.8.4 built for i386-linux-thread-multi
 
P

Paul Lalli

Randall said:
my $p = HTML::pullParser->new(
$wcontent,
start => 'tag, attr',
end => 'tag',
text => '@{text}',
report_tags => \@FORM_TAGS,
)
This works most of the times, but randomly the following error happens:

Odd number of elements in hash assignment at /usr/lib/perl5/HTML/PullParser.pm line 14.

Can you please explain to me what part of the documentation for
HTML::pullParser suggested that you could just pass the content as the
first argument to new(), rather than giving it in a key/value pair?
thread failed to start: Info not collected for any events at TWEtest.pl line 552
Use of uninitialized value in numeric gt (>) at TWEtest.pl line 151.
Use of uninitialized value in addition (+) at TWEtest.pl line 153.
Use of uninitialized value in addition (+) at TWEtest.pl line 155.
Use of uninitialized value in addition (+) at TWEtest.pl line 156.

Why are you even posting these warning messages when you clearly didn't
post the code that went along with them?
Anyone encounter this error, and if so, is there a solution?

Of course there is. Read the documentation, and program like it shows
you. Don't just make stuff up.

Paul Lalli
 
R

Randall S Benson

Paul,
Thanks for the advice. Please excuse me while I pull my ass out of the
alligator's mouth. I will be more careful next time.
Despite your quality suggestion, I did discover the error that I made.
When I was prewriting the code, before putting it in the existing program,
it does work with a static webpage with a local file path, but I missed
the part that says that content that is not an actual file it needs the
doc keyword.

I thank you for your kindness, and hope that others do not fall into the
trap that I did. This is why I am so rudely listing my mistake, and fix,
so that others can learn.

Thanks,
Randall S Benson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,181
Messages
2,570,969
Members
47,536
Latest member
VeldaYoung

Latest Threads

Top