Link to home
Start Free TrialLog in
Avatar of darkyla
darkyla

asked on

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!

S.
Avatar of inq123
inq123

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.

Cheers!
Avatar of darkyla

ASKER

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?

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of kandura
kandura

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of darkyla

ASKER

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?

Thanks...
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:
cgi-bin/myLib/LWP/Simple.pm

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.
Avatar of darkyla

ASKER

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 Simple.pm 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:

    #!/usr/bin/perl
    #
    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.
kandura,

I agree that sometimes CWD on some servers are not cgi-bin but a level above.  In those cases absolute path is better.
Avatar of darkyla

ASKER

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...