I'm trying to find a way to accomplish two things:
1) I have project files spread throughout various directories on my system,
and I want to have *one* line that I can include at the top of each file in
the project, either a "require" or a "use" line, that sets up variables and
settings that need to be constant across the whole project.
2) I have files named e.g. FileName.pm in a directory which is not part of
my path by default, but which I can add to @INC in a BEGIN block, and I
want to be able to "use" them in project files simply by writing
use FileName;
Here's the problem -- if any one step in the following logical sequence is
wrong, please let me know since that will fix the issue --
1) Since the project files are spread throughout a directory tree, it
appears that the line which appears at the top of every project file has to
be a "require" file and not a "use" file. This is because
use FileName;
always looks in the directory where perl is run from, which often won't be
my directory where I've put FileName.pm. So, the line at the top of each
project file is
require "/projname/FileName.pl";
2) Unfortunately "require" doesn't get executed until run time, which means
if I have statements in the code like
use ModuleName;
where ModuleName.pm is in a directory that was supposed to get added to
@INC by code somewhere in FileName.pl, then the script won't be able to
find it because "use ModuleName;" happens at compile time, before
FileName.pl gets require'd and adds the right directory to @INC.
So I can solve the problem if I can find out how to do any of the following:
- have "use" point to a .pm file using an absolute, rather than relative,
path, so that it will work no matter where the project file is located.
Unfortunately
use ::projname::FileName;
does not load the c:\projname\FileName.pm file -- I get the error:
>>>
Can't call method "import" without a package or object reference at test.pl
line 1.
BEGIN failed--compilation aborted at test.pl line 1.
>>>
This is with "FileName.pm" being a dummy file containing the single line
"1;". If I write
use FileName;
instead of 'use ::projname::FileName;', then I don't get this error (but
then the script has to be in the same directory as FileName.pm to work).
- modify @INC in some way that will be specific to this project but
wouldn't apply to any others.
Any suggestions?
-Bennett
[EMAIL PROTECTED] http://www.peacefire.org
(425) 649 9024
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users