Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Is it possible to use modules without installing them?

by Nemp (Pilgrim)
on Aug 31, 2002 at 15:16 UTC ( #194342=perlquestion: print w/ replies, xml ) Need Help??
Nemp has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I've been looking for a way to generate images on the fly and I found the rather helpful GD CPAN module.

Wonderful! I thought and downloaded it and played with it a little and then decided to run it online on my web-site. This is where my problem is... the distro of Perl on my website doesn't have GD installed and I am unable to install it there. Is there another way I can do this? Include the source for GD some other way than "use GD;"

I'm sorry if this is a rather basic question but I've been tearing my hair out for the last 2 hours searching with no luck so I thought I'd ask if anyone can tell me how or just point me to the relevant part of the FM :)

Thanks!
Neil

Comment on Is it possible to use modules without installing them?
Re: Is it possible to use modules without installing them?
by BrowserUk (Pope) on Aug 31, 2002 at 15:34 UTC

    In general, if the module concerned is a "pure perl" module, there is nothing (provided you take the copyrights etc with it) of including it into your script as source.

    However, many modules have XS and/or C components and they obviously won't work without their compiled bits.

    I'm not familiar with the internals of GD so don't know which is the case for it.

    Being a graphics module, it's quite likely that at least some of it has been optomised to C for speed?



    Well It's better than the Abottoire, but Yorkshire!
      Thanks for the reply!

      Unfortunately you've provided me with another question now, specifically for GD and for any other module generically, is there a way to find out if a module is "pure Perl"?

      I guess I could just go and look through the source code but I'm still pretty much a novice at Perl so I might skip parts I don't understand and not recognize them as being XS or C components. Maybe there is a module on CPAN that analyzes a given file to determine if it's pure Perl or not?

      Many thanks for any help and the help so far :)
      Neil
        You can tell if a module is pure Perl or not by examining the dslip information.

        One module which does this is CPANPLUS (it also does a whole lot more, including module installation without root access, which I recommend over including the module source in your program*). The default shell includes the 'l' command which will give information, including the language used.

        CPAN.pm might also give dslip info, but I don't know it well enough to say if it does or not.

        GD is C and Perl and a C compiler is needed. If your ISP allows you to use a compiler, you should still be able to install it without being root.

        [1] For instructions on how to do this with CPANPLUS, refer to the FAQ (available on the website).

Re: Is it possible to use modules without installing them?
by zentara (Archbishop) on Aug 31, 2002 at 16:36 UTC
     I havn't tried it yet, but it may be possible to put the GD package 
    on your remote machine if they let you compile. You should
    be able to ssh to your homedir and do it. Here is an excerpt from
    the mod-perl-in-homedirs.html.
    
    8.1. Installing Perl Modules into a Directory of Choice
    
       Since without superuser permissions you aren't allowed to install
       modules into system directories like /usr/lib/perl5, you need to find
       out how to install the modules under your home directory. It's easy.
    
       First you have to decide where to install the modules. The simplest
       approach is to simulate the portion of the / file system relevant to
       Perl under your home directory. Actually we need only two directories:
    
    /home/stas/bin
    /home/stas/lib
    
       We don't have to create them, since that will be done automatically
       when the first module is installed. 99% of the files will go into the
       lib directory. Occasionally, when some module distribution comes with
       Perl scripts, these will go into the bin directory. This directory
       will be created if it doesn't exist.
    
       Let's install the CGI.pm package, which includes a few other CGI::*
       modules. As usual, download the package from the CPAN repository,
       unpack it and chdir to the newly-created directory.
    
       Now do a standard perl Makefile.PL to prepare a Makefile, but this
       time tell MakeMaker to use your Perl installation directories instead
       of the defaults.
    
    % perl Makefile.PL PREFIX=/home/stas
    
       PREFIX=/home/stas is the only part of the installation process which
       is different from usual. Note that if you don't like how MakeMaker
       chooses the rest of the directories, or if you are using an older
       version of it which requires an explicit declaration of all the target
       directories, you should do this:
    
    % perl Makefile.PL PREFIX=/home/stas \
      INSTALLPRIVLIB=/home/stas/lib/perl5 \
      INSTALLSCRIPT=/home/stas/bin \
      INSTALLSITELIB=/home/stas/lib/perl5/site_perl \
      INSTALLBIN=/home/stas/bin \
      INSTALLMAN1DIR=/home/stas/lib/perl5/man  \
      INSTALLMAN3DIR=/home/stas/lib/perl5/man3
    
       The rest is as usual:
    
    % make
    % make test
    % make install
    
    
Re: Is it possible to use modules without installing them?
by dws (Chancellor) on Aug 31, 2002 at 17:12 UTC
    ... the distro of Perl on my website doesn't have GD installed and I am unable to install it there.

    GD has been around for quite a while now. If you're ISP doesn't have it, or if you can't get them to install it for you, treat this as a big warning flag, and start looking around for a new, Perl-friendly ISP.

Re: Is it possible to use modules without installing them?
by sharkey (Scribe) on Aug 31, 2002 at 19:22 UTC
    If you're only problem is being able to type 'make install', you can still easily use the module.

    Assuming you have a shell account on the ISP, do the usual:
    UPDATE: see the reply. Those steps work even better.

    tar -zxvf GD-1.41.tar.gz cd GD-1.41 perl Makefile.PL make make test
    (If you didn't make it this far because of missing libs, etc, you're out of luck, unless you can download and build those in your shell directory too. And yes, GD does use XS: notice the GD.xs file in the distribution.)

    Now, in the top of your scripts which want to use GD, do this:

    use lib '/home/neil/GD-1.41/blib/lib','/home/neil/GD-1.41/blib/arch'; use GD;
    You'll see a line like this at the top of the test file, since the tests have to run without the module being installed.

    BTW, use lib is like the following, but with more error-checking:

    BEGIN { unshift (@INC, 'directory'); }
    ~ John Williams
Re: Is it possible to use modules without installing them?
by gmpassos (Priest) on Aug 31, 2002 at 20:51 UTC
    You can put the module in the same directory of the script, in this case, I think, your cgi-bin.

    Let's use FOO.pm like a module, with a XS too. 1st get it, compile and install in some Perl interpreter that you have access, with the same OS of your server. They will be instaled at: (let's use Perl for Win32 like example (path more simple))
    c:/perl/site/lib/FOO.pm
    c:/perl/site/lib/auto/FOO/FOO.dll

    To enable this module in the server just copy all the stuf from FOO.pm inside site/lib to your server, with the same path. In the cgi-bin will be like:
    .../cgi-bin/FOO.pm
    .../cgi-bin/auto/FOO/FOO.dll

    This will work fine, because Perl use your local path like a lib directory too (see @INC). About the directory auto/FOO, copy everything inside to the server, not only the DLL. And if your module have other sub-modules you need to copy the directory site/lib/FOO too.

    Using this steps you don't need a shell acount to do that, just a FTP! Don't forget to send the .pm like ANSII and the DLL (or .so on linux) like binary!

    Graciliano M. P.

    "The creativity is the expression of the liberty".

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://194342]
Approved by Mr. Muskrat
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2014-08-29 04:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls