J
Jonathan
This is an embarrassingly simple question, but I'm trying to get
HTML::TokeParser to execute an example even simpler than the one given as an
example in the docs.
I expect to get output of "3" from the program Instead, I get "0."
What is the trivial reason for this? Is there a problem with my use
of __DATA__, or my reference to main:
ATA? Is the central loop not
working?
I hope that I have done enough of my homework on this to warrant a meaningful
response. If I have to go back to perlopen or perlreftut, please let me know.
Here is my sample program:
#!/usr/bin/perl -w
use warnings;
use strict;
use diagnostics;
use HTML::TokeParser;
my $fh = \<main:
ATA>;
my $p = HTML::TokeParser->new($fh) || die "Bad open: $! \n";
my $heading3s = 0;
while (my $token=$p->get_tag("<h3>")){
$heading3s++;
}
print "Number of Level 3 Headings: $heading3s\.\n";
__DATA__
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>Test Page</title>
</head>
<body>
<h3>Alpha</h3>
<h3>Beta</h3>
<h3>Gamma</h3>
</body>
</html>
HTML::TokeParser to execute an example even simpler than the one given as an
example in the docs.
I expect to get output of "3" from the program Instead, I get "0."
What is the trivial reason for this? Is there a problem with my use
of __DATA__, or my reference to main:
working?
I hope that I have done enough of my homework on this to warrant a meaningful
response. If I have to go back to perlopen or perlreftut, please let me know.
Here is my sample program:
#!/usr/bin/perl -w
use warnings;
use strict;
use diagnostics;
use HTML::TokeParser;
my $fh = \<main:
my $p = HTML::TokeParser->new($fh) || die "Bad open: $! \n";
my $heading3s = 0;
while (my $token=$p->get_tag("<h3>")){
$heading3s++;
}
print "Number of Level 3 Headings: $heading3s\.\n";
__DATA__
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>Test Page</title>
</head>
<body>
<h3>Alpha</h3>
<h3>Beta</h3>
<h3>Gamma</h3>
</body>
</html>