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

Hi. The problem is that my server does not have the neccesary modules for me to read a gzip'ed file. I have tried 'use'ing several of the zip/compressing modules at cpan and none of them are installed. Since I do not have access to the server other than to my user folder, I need to know if there is anyway of uploading a module and using it from my user directory without really installing it into perl.

OR...     If the above is not possible, I could find a way to include the code in a normal perl script. It would be acceptable to simply inflate the file to another one and save it, but I think the program might run faster if I can read straight from the gzip'ed file as I think the bottleneck is accessing the file, not the CPU. But still right now I'd just like to get it to work. Many Thanks in advance.

Replies are listed 'Best First'.
Re: reading a gzip'ed file
by voyager (Friar) on Jul 12, 2001 at 08:07 UTC
    Assuming the module can be installed just by copying the Module.pm file, you can use the module by doing a use "path to module";. Since the @INC includes ".", you can test this by copying the module to the same directory as your script.
Re: reading a gzip'ed file
by synapse0 (Pilgrim) on Jul 12, 2001 at 12:55 UTC
    well, providing all else fails, you can still backtick it... $file = `/bin/gunzip -c file.gz`; will send the output to STDOUT, which will be placed in $file for you to play with.
    It's ugly, but it works.
    -Syn0

    word of caution: if you plan on using a variable for the filename and it comes from untrusted sources, make sure you have taint mode on and do proper checking on what is in the variable... backticks are evil evil little creatures.
Re: reading a gzip'ed file
by MZSanford (Curate) on Jul 12, 2001 at 14:05 UTC
    When the modules are not available, i have used the following in the past :
    my $path_to_gzip = '/usr/bin/gzip'; ## gzip -dc is equiv to gzcat open(INFILE,"$path_to_gzip -dc |") || die "Could not start gzip : $!\n +"; while (my $line = <INFILE>) { ## process data } close(INFILE);

    Calm begets calm
Re: reading a gzip'ed file
by bikeNomad (Priest) on Jul 12, 2001 at 21:16 UTC
    You can install modules locally. You can't successfully install Compress::Zlib (which is what you need) by copying its .pm file. What you should do is to go through the usual installation of the module but supply its location:

    perl Makefile.PL LIB=/full/path PREFIX=/full/path make make install
    Note that you must have an absolute path for this to work. Now when you run your program, just add /full/path to its search path:

    use lib '/full/path'; use Compress::Zlib;