Discussion:
How ro specify path in "use lib qw()"
Mimi Cafe
2010-04-11 23:32:12 UTC
Permalink
My program is in the same directory as my module directory, but when I use
relative path in use lib, Perl doesn't find the module.



use lib qw(MyModule/), use lib qw(./MyModule/), use lib qw(MyModule) or use
lib qw(./MyModule/) # these don't work.



use lib qw(/var/www/cgi-bin/MyProject/) # This work fine, but I want to
avoid absolute path because it will not work on SuSe Linux for example.





I have tried various ways of specifying relative path and they don't work
except the absolute path from the / (file system root). I don't want to use
the absolute path it will break if my program is not still on RedHat Linux
where httpd docs are store in /var/www/*.



What is the recommended way of specifying the path in the CGI application?
It is relate to the web server document root as the file system / dir?





Mimi
Shlomi Fish
2010-04-12 10:07:20 UTC
Permalink
Hi Mimi,
Post by Mimi Cafe
My program is in the same directory as my module directory, but when I use
relative path in use lib, Perl doesn't find the module.
use lib qw(MyModule/), use lib qw(./MyModule/), use lib qw(MyModule) or use
lib qw(./MyModule/) # these don't work.
use lib qw(/var/www/cgi-bin/MyProject/) # This work fine, but I want to
avoid absolute path because it will not work on SuSe Linux for example.
I have tried various ways of specifying relative path and they don't work
except the absolute path from the / (file system root). I don't want to use
the absolute path it will break if my program is not still on RedHat Linux
where httpd docs are store in /var/www/*.
What is the recommended way of specifying the path in the CGI application?
It is relate to the web server document root as the file system / dir?
You can try the solution given in:

http://use.perl.org/~Aristotle/journal/33995

"use lib" can do relative paths just fine (as in the examples you have given),
but the fact that this is a server-side program may mess with the current
working directory. You can experiment by debugging stuff using print and
Data::Dumper to see.

Regards,

Shlomi Fish
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
The Case for File Swapping - http://shlom.in/file-swap

Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.

Please reply to list if it's a mailing list post - http://shlom.in/reply .
--
To unsubscribe, e-mail: beginners-***@perl.org
For additional commands, e-mail: beginners-***@perl.org
http://learn.perl.org/
Loading...