Whenever I run TokeParser I get this undefined error. I think it’s because the last thing it pulls from the HTML is ‘undef’ which is causing the error but I’m sure if that’s correct or what to do if it is from that.
#!usr/bin/perl
use warnings;
use strict;
use HTML::TokeParser;
sub findTokens {
my $htmlFileName = "83.html";
my $p = HTML::TokeParser->new($htmlFileName);
my @tokens;
while (my $newChunk = $p->get_token) {
if ($newChunk->[0] eq 'T') {
my @lineArray = split(' ', $newChunk->[1]);
foreach my $i (@lineArray) {
if ( lc($i) =~ /^[a-z]*\-?'?s?$/) {
push(@tokens, lc($i));
}
}
}
}
return @tokens;
}
It’s obviously
$pthat’s undef, and$pis the result ofHTML::TokeParser->new($htmlFileName). That means there was an error opening the file. As suggested in the Synopsis, use the following to determine what that error is: