G'day sbasbasba,
Welcome to the monastery.
"Can't locate object method "new" via package "HTML::TreeBuilder::XPath" at /System/Library/Perl/Extras/5.10.0/Web/Scraper.pm line 115, <F1> line 1."
That pathname (/System/Library/Perl/...) indicates your OS is Mac OS X and you're using the system Perl (i.e. the version of Perl installed by Apple for its own use).
You have Web::Scraper installed in /System/Library/Perl/Extras/5.10.0/: this means you've modified your system Perl; I don't know what other modifications you've made.
It's generally not a good idea to alter the system Perl.
See the responses to "Are there any major Perl issues with Mac OS X Lion?": I posted this question a couple of years ago when I first started using Perl on a Mac; I chose the perlbrew option (and have no problems after 2 years of use and multiple Perl upgrades).
I'd recommend you look into perlbrew or an equivalent solution.
Your current problem is probably related to if, and where, you have HTML::TreeBuilder::XPath installed.
You may also have other versions of Perl installed.
Without more information, I can only provide troubleshooting tips:
-
The shebang line at the start of your script (#!/usr/bin/perl) indicates that the system Perl (/usr/bin/perl) should be used to run the script. Use the "which perl" command to see if that's the default Perl: you may get something like /opt/local/bin/perl if you've installed MacPorts.
-
Find out where your Perl module libraries are. "perl -V" will list these under @INC: for the default Perl; for a specific Perl, use a full pathname, e.g. "/opt/local/bin/perl -V".
-
Determine how you're installing Perl modules. cpan is a fairly typical utility for this. Use "which cpan" to see the full path and compare with paths to perl.
-
Search for .../HTML/TreeBuilder/XPath.pm on your system. Assuming it has been installed, it's probably in one of the paths listed under @INC:. If you can't find it, install it; if it's in an unexpected place, don't try to copy or move it, reinstall it.
-
Your problem might be fixed by changing your shebang line to whatever your default Perl is.
For all my scripts, I use "#!/usr/bin/env perl" which automatically uses the current default.
[Aside: I noticed you removed part of your original post and replaced it with new content.
Please don't do this: it often invalidates comments already made; it can also be useful to subsequent readers to see what was considered and then discarded (i.e. others can learn from your mistakes).
The correct way to deal with this is described in "How do I change/delete my post?".]
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.