For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > April 2005 > path problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author path problem
Andrew Kennard

2005-04-06, 8:55 pm

Hi all

Iv'e downloaded a pdf module from CPAN and am trying to use it in my
webspace provided by Demon Internet (www.demon.net) but no matter what I try
it cannot 'find' the module called Reuse.pm which IS in the same directory
as the following script.

!/usr/bin/perl
use lib "$ENV{'DOCUMENT_ROOT'}/pdftest";
use CGI::Carp qw(fatalsToBrowser);
use Reuse;
use PDF::Reuse;
print "Content-type: text/html\n\n";
print "<HTML><BODY>Finished</BODY></HTML>";


It stops on the "use PDF::Reuse;" statement saying it can't find the module
at yet the Use Reuse does not cause an error and the error shows the @inc
path which contains the full path to my working directory.

I've tried Demon's technical support but they offered very little advice

Thanks in advance for your help

Andrew Kennard



Zentara

2005-04-08, 3:55 pm

On Wed, 6 Apr 2005 16:46:43 +0100, a.kennard@btinternet.com (Andrew
Kennard) wrote:

>Iv'e downloaded a pdf module from CPAN and am trying to use it in my
>webspace provided by Demon Internet (www.demon.net) but no matter what I try
>it cannot 'find' the module called Reuse.pm which IS in the same directory
>as the following script.
>
>!/usr/bin/perl
>use lib "$ENV{'DOCUMENT_ROOT'}/pdftest";
>use CGI::Carp qw(fatalsToBrowser);
>use Reuse;
>use PDF::Reuse;
>print "Content-type: text/html\n\n";
>print "<HTML><BODY>Finished</BODY></HTML>";
>
>
>It stops on the "use PDF::Reuse;" statement saying it can't find the module
>at yet the Use Reuse does not cause an error and the error shows the @inc
>path which contains the full path to my working directory.
>
>I've tried Demon's technical support but they offered very little advice


2 things to try:

Instead of:
use lib "$ENV{'DOCUMENT_ROOT'}/pdftest";
try
use lib ".";

In "." , create a directory called PDF, and put Reuse.pm
into PDF.

There is an internal naming of modules, at the top of the .pm
file, where the package is declared.
In your case, Reuse.pm should have "package PDF::Reuse" at
the top. You can change that to just "package Reuse" and avoid having
the PDF directory.

I don't know why the "use lib "$ENV{'DOCUMENT_ROOT'}/pdftest";
dosn't work, but I'm guessing Perl dosn't like nested variables in it's
use statements?




--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
Shaun Fryer

2005-04-08, 3:55 pm

> >use lib "$ENV{'DOCUMENT_ROOT'}/pdftest";

use lib is done at compile time. the %ENV isn't available til run-time IIRC.
Peter Scott

2005-04-09, 3:55 pm

On Fri, 08 Apr 2005 11:59:12 -0400, Shaun Fryer wrote:
>
> use lib is done at compile time. the %ENV isn't available til run-time IIRC.


False:

$ perl -le 'print grep /peter/ => @INC'

$ perl -le 'use lib $ENV{HOME}; print grep /peter/ => @INC'
/home/peter
$

--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com