ISP Missing Modules: Can I reference locally?

Hello -

Let me preface with the disclaimer that I'm a CGI script end-user. I don't know how to write in Perl.

Earthlink is my ISP, and they are missing the LWP, LWP::UserAgent, and LWP::Simple modules that I apparently need for several scripts. I've called them and they refuse to install the modules for me (%@#$%).... some drivel about "optimal configuration for all end users".

Can I get around this? Can I somehow load these libraries locally and call them in the beginning of the script somehow?

Help! Thanks!

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

kanduraConnect With a Mentor Commented:
Do you have shell access to that server?

If not, then
- place your libraries in a subdirectory lib/ somewhere above your cgi-bin directory
- make sure that you place them in correctly named directories, e.g. LWP::Simple should be in
- add the following line to the top of your script.
    use lib '/my/full/path/to/lib';

That's all there's to it, provided these modules are pure perl, and have no other unmet dependencies.
Hi darkyla,

Most of the perl modules can be used locally as long as you set lib path correctly using either environment variables or "use lib" statement.  I'm not totally sure about these ones since I installed them in my default system directory, but I think it'd work.

darkylaAuthor Commented:
Great! Sounds promising.... but how do I do it?  I'm on a UNIX server, if that makes a difference in terms of the syntax for calling the library. Do I need to use an absolute path or a relative path?  What's the syntax?

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

darkylaAuthor Commented:
I'm changing the point value on the question, since in my ignorance I now realize there are more questions related to this.  :)

I've installed a local copy of the core Windows distribution of Perl from CPAN.  This has the LWP modules I need, but now I'm not sure how to proceed. Do I copy the appropriate .pm files to  a directory in my cgi bin and reference their location in the script? Do I need to put more than those two or three files up to make the libraries function?

I would suggest putting lib under your cgi-bin directory because relative path makes it easy to migrate from server to server (you can even test it locally before moving to your server), also saves some trouble finding out full path.

So I would put a directory myLib under cgi-bin directory where your perl CGI is located.  Then in the perl script use
use lib 'myLib';
Of course as I said earlier you need to keep directory structure, in my example it'd be:

Just use your FTP client to upload the directories and files there.
Check the readme for LWP, LWP::Simple, etc.  They'd tell you dependencies.  If there's no dependency on other modules, no autoload, then yes, you can simply just copy the windows perl modules over to your web server's cgi-bin and reference them as I described above.
darkylaAuthor Commented:
How do I know if my modules are pure Perl?  And...

Do I need to use the absolute path (e.g. www/user/s4/dwiresourcecenter/webdocs/lib/LWP) or the relative path (e.g. ../lib/LWP).  

Kandura, if I understood you correctly, I'm only putting the file (and the other appropriate .pm files)  into the library directory, and nothing else?
no, he's just making an example.  You do need to put everything that's needed there.  As I said, check readme.

It's always pure perl (well, almost always) unless it calls autoload function, which uses platform dependent binaries, which means trouble.
You can try using a relative path, and put your 'lib' directory in the cgi-bin dir, but I have dealt with several setups where the current working directory of my scripts was not the cgi-bin directory. I prefer to use absolute paths just to avoid problems.

You will have to upload the entire LWP directory.
And most likely you'll run into other dependencies, as LWP::UserAgent depends on e.g. HTTP::Request.

Just create a simple script to see if you've got everything:

    use CGI;
    use CGI::Carp qw/fatalsToBrowser/;
    my $q = CGI->new();
    print $q->header();
    eval {
            require LWP::Simple;
    print  $q->pre("$@") if $@;
To see if a module is not purely written in perl, you could check the perl/site/lib/auto directory of your local installation. If there's anything in there other than a file named .packlist, such as dll's, then you can be sure it's *not* a pure perl module.
But my sample script would give you a nice error message as well.

I agree that sometimes CWD on some servers are not cgi-bin but a level above.  In those cases absolute path is better.
darkylaAuthor Commented:
Y'all are brillant.  After some initial struggles figuring out how to build Perl modules correctly, it all works like a charm.  Thank you SO much! A whole new world has opened up...
All Courses

From novice to tech pro — start learning today.