Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Perl on Win32, with Apache

Reply
Thread Tools

Perl on Win32, with Apache

 
 
Regent
Guest
Posts: n/a
 
      03-05-2004
I have a Perl-based web site, of which each script must "require" a
commonstuff.pl that simply defines some common subroutines and
constants. If I don't put commonstuff.pl in any of the @INC paths, how
should I efficiently include it in each script, avoiding such lines as

require "d:/wwwroot/cgi-bin/commonstuff.pl";

Of course I also tried the following:

unshift (@INC, "d:/wwwroot/cgi-bin");
require ("commonstuff.pl");

However I hate to do such path-specific things in the many scripts. Thanks!

Regent
 
Reply With Quote
 
 
 
 
gnu valued customer
Guest
Posts: n/a
 
      03-05-2004
hello,
"Regent" <> wrote in message
news:c29c2d$1pkd$...
> I have a Perl-based web site, of which each script must "require" a
> commonstuff.pl that simply defines some common subroutines and
> constants. If I don't put commonstuff.pl in any of the @INC paths, how
> should I efficiently include it in each script, avoiding such lines as
>
> require "d:/wwwroot/cgi-bin/commonstuff.pl";
>
> Of course I also tried the following:
>
> unshift (@INC, "d:/wwwroot/cgi-bin");
> require ("commonstuff.pl");
>
> However I hate to do such path-specific things in the many scripts.

Thanks!
>
> Regent


use File::Basename;
chdir(dirname( $0 ));
require("commonstuff.pl");

No hard-coded path here, so it might be what you want.

good luck,
Mark


 
Reply With Quote
 
 
 
 
gnari
Guest
Posts: n/a
 
      03-05-2004
"Regent" <> wrote in message
news:c29c2d$1pkd$...
> I have a Perl-based web site, of which each script must "require" a
> commonstuff.pl that simply defines some common subroutines and
> constants. If I don't put commonstuff.pl in any of the @INC paths, how
> should I efficiently include it in each script, avoiding such lines as
>
> require "d:/wwwroot/cgi-bin/commonstuff.pl";
>
> Of course I also tried the following:
>
> unshift (@INC, "d:/wwwroot/cgi-bin");
> require ("commonstuff.pl");
>
> However I hate to do such path-specific things in the many scripts.

Thanks!

change it into a module Commonstuff.pm and drop it in @INC and
use Commonstuff;

if you are using mod_perl, I think you can have Apache pre-load the module,
so you do not need the use line even
this may not apply on windows. actually, this might not apply outside
of my imagination, as I am too lazy to look it up to confirm

gnari



 
Reply With Quote
 
gnari
Guest
Posts: n/a
 
      03-05-2004
"gnu valued customer" <> wrote in message
news:5WW1c.62000$...
> hello,
> "Regent" <> wrote in message
> news:c29c2d$1pkd$...
> > I have a Perl-based web site, of which each script must "require" a
> > commonstuff.pl that simply defines some common subroutines and
> > constants. If I don't put commonstuff.pl in any of the @INC paths, how
> > should I efficiently include it in each script, avoiding such lines as
> >
> > require "d:/wwwroot/cgi-bin/commonstuff.pl";

[snip]

> use File::Basename;
> chdir(dirname( $0 ));
> require("commonstuff.pl");
>
> No hard-coded path here, so it might be what you want.


will not work on all webserver setups, so try it before changing
3000 scripts.

anyways the chdir is disgusting. why not:
use File::Basename;
require(dirname($0) . "commonstuff.pl");

gnari



 
Reply With Quote
 
sangeetha
Guest
Posts: n/a
 
      03-05-2004
Create package file .pm file and place in the current directory. "use
package"
In anotherway, in the configuration file your have specified the
location HTTPROOT(???) directory for the application. So give relative
path from that ROOT in the "require x/y/z/fileame".

Sangetha

Regent <> wrote in message news:<c29c2d$1pkd$>...
> I have a Perl-based web site, of which each script must "require" a
> commonstuff.pl that simply defines some common subroutines and
> constants. If I don't put commonstuff.pl in any of the @INC paths, how
> should I efficiently include it in each script, avoiding such lines as
>
> require "d:/wwwroot/cgi-bin/commonstuff.pl";
>
> Of course I also tried the following:
>
> unshift (@INC, "d:/wwwroot/cgi-bin");
> require ("commonstuff.pl");
>
> However I hate to do such path-specific things in the many scripts. Thanks!
>
> Regent

 
Reply With Quote
 
Regent
Guest
Posts: n/a
 
      03-06-2004
gnari wrote:

> "gnu valued customer" <> wrote in message
> news:5WW1c.62000$...
>
>>hello,
>>"Regent" <> wrote in message
>>news:c29c2d$1pkd$...
>>
>>>I have a Perl-based web site, of which each script must "require" a
>>>commonstuff.pl that simply defines some common subroutines and
>>>constants. If I don't put commonstuff.pl in any of the @INC paths, how
>>>should I efficiently include it in each script, avoiding such lines as
>>>
>>> require "d:/wwwroot/cgi-bin/commonstuff.pl";

>
> [snip]
>
>
>>use File::Basename;
>>chdir(dirname( $0 ));
>>require("commonstuff.pl");
>>
>>No hard-coded path here, so it might be what you want.

>
>
> will not work on all webserver setups, so try it before changing
> 3000 scripts.
>
> anyways the chdir is disgusting. why not:
> use File::Basename;
> require(dirname($0) . "commonstuff.pl");
>
> gnari
>
>
>

Yes, that's the solution, except that with -T in the shebang, I must do
something with dirname($0) before concatenating the path with
commonstuff.pl.

Thanks folks!

Regent
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PERL can't open file for logging (world writable directory Windows XP Home/ Active Perl / Apache) PGPS Perl Misc 10 11-14-2006 01:40 AM
AXIS jars org.apache.axis.wsi.* and org.apache.axis.transport.jms.* unkwb@web.de Java 0 02-23-2005 04:02 PM
#!perl instead of #!/usr/bin/perl on a Unix/Apache webserver joe Perl Misc 8 11-14-2003 10:58 AM
Use perl in apache without #!/path/to/perl Kostas Hatzikokolakis Perl Misc 2 10-19-2003 03:02 AM
How to test speed difference of Perl/Apache and SSI/Apache The Poor Perl Misc 2 09-27-2003 12:26 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57