Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Oh great Perl Monks, I need help. The server that I use doesn't have the module HTML::Template. Is there a way to instead have my script reference to it? Could I use another module to get it for my script? Or could I possibly place it in one of my directories and maybe use it in my script, say by "linking" to it, for lack of a better word. Can I also modify the @INC special array? If not, then might have a different suggestion?

Replies are listed 'Best First'.
Re: If it don't have a module...
by dws (Chancellor) on Apr 18, 2002 at 02:43 UTC
    Put HTML::Template into a subdirectory ('lib') of the directory your application (or CGI) is in, then add   use lib qw(lib); at the top of your script. It side-effects @INC.

      This is a good solution because it will work even if you only have FTP access to a site (not login). Also, HTML::Template is only one file to install (Template.pm within the HTML folder).

      bassplayer

Re: If it don't have a module...
by Kanji (Parson) on Apr 18, 2002 at 02:48 UTC

    You can cut n' paste a required module directly into your script (either before your own code, or afterwards if you wrap it in a BEGIN { }) and have it work.

    However, that only works if the module in question is pure Perl, so if it isn't -- or you prefer a cleaner solution -- you can try installing your personal copy and then use libing, which will modify @INC for you.

        --k.


Re: If it don't have a module...
by chiller (Scribe) on Apr 18, 2002 at 04:42 UTC
    Try this (lifted out of _Programming Perl_):
    Download the source of the module, open it up, and when you need to run "perl Makefile.PL", type this instead:

    perl Makefile.PL LIB=/my/dir/perllib \
      INSTALLMAN1DIR=/my/dir/man/man1 \
      INSTALLMAN3DIR=/my/dir/man/man3 \
      INSTALLBIN=/my/dir/bin \
      INSTALLSCRIPT=/my/dir/scripts
    
    Then add:
    use lib q{/my/dir/perllib};
    to your script...

    Related: Does anyone know how to get around some of the dependencies going on using this method? Say I need module x and I install it in /my/dir/perllib, and it depends on module y which is somewhere else. Is there anyway to have the Makefile.PL look for the library besides the defaults? I guess this would be like setting an environment variable for @INC, but I assume it is another command-line arg.

Re: If it don't have a module...
by Anonymous Monk on Apr 18, 2002 at 03:05 UTC
    Okay. I'll try that first suggestion.