in reply to Possible HTML::TokeParser::Simple Bug
As Thelonius has pointed out, this is not a bug in HTML::TokeParser::Simple, but a feature of HTML::Parser. Converting your code to HTML::TokeParser demonstrates this (and show why the Simple module is easier to use. Once again, I had to look up the array indices :)
#!/usr/bin/perl -w use strict; use HTML::TokeParser; my $html = q( <option value="STAFE">STAFE - 900 - BEN PROG - Food Assistance</option +> <option value="STAM7">STAM7 - 900 - BEN PROG - Med Asst - Lynchbrg</op +tion> <option value="STAM8">STAM8 - 900 - BEN PROG - Med Asst - Marion</opti +on> <option value="STAM9">STAM9 - 900 - BEN PROG - Med Asst - Petrsbrg</op +tion> <option value="STAMA">STAMA - 900 - BEN PROG - Medical Assistance</opt +ion> <option value="STATA">STATA - 900 - BEN PROG - Economic Assistance</op +tion> <option value="STATR">STATR - 900 - BEN PROG - Training Development</o +ption>); my $p = HTML::TokeParser->new(\$html); while(my $token = $p->get_token){ if($token->[0] eq 'T'){ my $text = $token->[1]; next unless $text =~ /\S/; print "[$text]\n"; } }
To be perfectly honest, though, I had not encountered this problem before. I think I'm going to think about the best way to make HTML::TokeParser::Simple DWIM. At the very least, I should update the docs to mention this (and correct a few tyops in the docs).
Cheers,
Ovid
New address of my CGI Course.
Silence is Evil (feel free to copy and distribute widely - note copyright text)
|
|---|