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
|