I'm getting the error
Undefined subroutine &HTML::Entities::decode_entities called`
using LWP::UserAgent, although the module is there, as well as the HTML::Parser module.
I suspect it has something to do with XS modules missing, since the function in question seems to be implemented in XS, but I am at a loss.
-
Are you missing this line:
use HTML::Entities;
From the HTML::Entities CPAN page, it should be used like this:
use HTML::Entities; my $a = "Våre norske tegn bør æres"; decode_entities($a); encode_entities($a, "\200-\377");
If you think there is something wrong with the HTML::Entities package, you can check the source on your system. From bash:
vim $(perldoc -l HTML::Entities)
Once the file is opened in your text editor, you can check that the subroutine is defined. I suspect that the package is correct though, it is more likely that the package isn't "used".
You can also test this at the command line to see if it works outside your program:
perl -MHTML::Entities -le 'print HTML::Entities::decode_entities( "Våre norske tegn bør æres" )'
heeen : I tried explicitly using the module as a test and it didn't work. It also doesn't work inside LWP::UserAgent.gpojd : Does the perl one-liner work? Did you check the package to see if the subroutine was defined? If all that checks out, is it possible to add your code to the post?Telemachus : Can you post fuller code, please? I've used the current version of HTML::Entities recently, and it works fine. So I don't think it's the module.ysth : @gpojd, if you bother to look at the current code, you will see that the subroutine is *not* defined in the Entities.pm file, intentionally: http://cpansearch.perl.org/src/GAAS/HTML-Parser-3.60/lib/HTML/Entities.pm : require HTML::Parser; # for fast XS implemented decode_entitiesgpojd : @ysth, I could have sworn I had it defined on my version when I originally answered this. I am not at that computer now, and can't check. Either way, some of my instructions would have led him to "require HTML::Parser;# for fast XS implemented decode_entities" and probable answered his question. -
Recent versions of HTML::Entities depend on getting the decode_entities routine by loading the HTML::Parser module's XS component. Since the two modules are distributed together, this should not be a problem, but it's possible you have an older HTML::Parser version that didn't use XS instead (or multiple versions of HTML::Parser installed, with the wrong one being found first).
Check the $VERSION in HTML::Parser, look up that distribution on http://search.cpan.org/dist/HTML-Parser, and verify that distribution has the version of HTML::Entities that you have.
0 comments:
Post a Comment