LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-02-2006, 09:45 AM   #1
Suinatsa
Member
 
Registered: Jul 2004
Distribution: Slackware, Suse
Posts: 46

Rep: Reputation: 15
Perl scripts in different location


Hey guys,

we just bought a web-project which uses perl scripts.
Now we have a problem to get it up and running. The guy who wrote the whole thing did not leave his perl scripts in the regular folders which are defined in @INC but in a different one.

Well one way to get it to work is to edit every single file and add the line use "/my/dir/" but that is not an option since there are hundreds of files.

Is there any way to edit the @INC array globally so that I can add the dir to it?

Or any other option?

THX

Suinatsa
 
Old 05-02-2006, 09:56 AM   #2
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 40
If you can afford a change to the way Perl is invoked, you can use the -I option to add the immediately proceding directory to the @INC array. For example, `perl -I/my/dir script.pl`. I'm pretty sure that will not overwrite what's already in @INC, but I'm not positive. You'll find out the first time you try it; but don't worry, it won't damage anything.
 
Old 05-02-2006, 10:00 AM   #3
Suinatsa
Member
 
Registered: Jul 2004
Distribution: Slackware, Suse
Posts: 46

Original Poster
Rep: Reputation: 15
Hey,

thanks for the fast reply!

I should have said it the first time! We use mod_perl with the apache to invoke the scripts. Therefore we cannot use the your way . Any other idea though?

THX

Suinatsa
 
Old 05-02-2006, 10:20 AM   #4
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 40
OK, according to some mod_perl documentation, modifying @INC during script execution will not affect anything other than the currently executing script, so that's out. But, it does say you can change @INC to take effect at server startup and therefore be used by any script that may run. Summarised, you should be able to do
Code:
PerlSetEnv PERL5LIB /home/httpd/perl
in your mod_perl configuration file. But here's the link: @INC and mod_perl.
 
Old 05-02-2006, 10:22 AM   #5
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 40
Yay, stupid login activity timeout tricked me into making a dupe. Sorry about that. Edited the dupe away so I don't take up too much extra space.

Last edited by taylor_venable; 05-02-2006 at 10:25 AM.
 
Old 05-02-2006, 11:32 AM   #6
Suinatsa
Member
 
Registered: Jul 2004
Distribution: Slackware, Suse
Posts: 46

Original Poster
Rep: Reputation: 15
Hey,

cool that's something I can work with.
It is not working right now. I inserted the line

PerlSetEnv PERL5LIB /my/dir in the mod_perl.conf.

So thats how my mod_perl.conf file looks like but it is not working right now!

<Directory "/srv/www/perl-lib">
AllowOverride None
Options None
Order allow,deny
Deny from all
</Directory>

<IfModule mod_perl.c>
PerlRequire "/etc/apache2/mod_perl-startup.pl"
PerlSetEnv PERL5LIB /srv/www/homepage24/html/cgi-bin
# <Location /cgi-bin/>
# # mod_perl mode
# SetHandler perl-script
# PerlResponseHandler ModPerl::Registry
# PerlResponseHandler ModPerl::PerlRun
# PerlOptions +ParseHeaders
# Options +ExecCGI
# </Location>
ScriptAlias /cgi-perl/ "/srv/www/cgi-bin/"
<Location /cgi-perl>
# perl cgi mode
SetHandler perl-script
PerlResponseHandler ModPerl::PerlRun
PerlOptions +ParseHeaders
Options +ExecCGI
</Location>

# The /cgi-bin/ ScriptAlias is already set up in httpd.conf

</IfModule>

# vim: ft=apache

Do you know where I have to insert the line we were talking about?

THX

Suinatsa
 
Old 05-02-2006, 02:00 PM   #7
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 40
I'll admit that I don't know much about mod_perl, but from this post it seems like it might have to be inside a <Location> block. If that doesn't work, I'm not sure. You might also want to check out the Practical mod_perl book.

Edit: Also, take a look at the logs, if you've got access to them. At best case, something is writing some error messages in there that will make everything clear.

Last edited by taylor_venable; 05-02-2006 at 02:07 PM.
 
Old 05-02-2006, 03:03 PM   #8
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 30
Quote:
Well one way to get it to work is to edit every single file and add the line use "/my/dir/" but that is not an option since there are hundreds of files.
Why not just write a (perl) script to automate it?
 
Old 05-03-2006, 06:04 AM   #9
muha
Member
 
Registered: Nov 2005
Distribution: xubuntu, grml
Posts: 451

Rep: Reputation: 37
Quote:
Originally Posted by ioerror
Why not just write a (perl) script to automate it?
Yeah, taylor_venable (sorry i meant Suinatsa): If you'd give an actual example of the change you'd want to make. I'm sure it shouldn't be too hard to use sed or something similar for it.

Last edited by muha; 05-04-2006 at 02:31 AM.
 
Old 05-03-2006, 12:06 PM   #10
Suinatsa
Member
 
Registered: Jul 2004
Distribution: Slackware, Suse
Posts: 46

Original Poster
Rep: Reputation: 15
Hey,

thanks for all the helpful replies. I found out what you have to do.
It might work with the

PerlSetEnv PERL5LIB /my/dir
in the mod_perl.conf file but it did not work for me.

I edited /etc/apache2/mod_perl-startup.pl
and added my directories to the

use lib qw(/my/dirs)

line!

Suinatsa
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
location startup scripts megadeth Linux - Software 2 05-22-2005 07:31 AM
perl scripts mimf Linux - Newbie 3 12-01-2003 11:10 PM
reading cd's and location of init scripts TheOneAndOnlySM Slackware 1 10-13-2003 07:18 AM
Combining 2 perl scripts together meluser Programming 5 03-18-2003 06:46 AM
Default Perl Location in Linux Mandrake 8 ? Mystikal Linux - General 1 09-18-2001 08:50 PM


All times are GMT -5. The time now is 07:35 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration