I lied. My modification does NOT work.
It is too early in the day to be burned out already. I think I will go
do something else!
-------- Original Message --------
Subject: More on t1.pl mylib issues
Date: Sat, 27 Jan 2007 11:18:04 -0500
From: Malcolm Nooning <[EMAIL PROTECTED]>
To: [email protected] <[email protected]>
Hello,
The "Re: More on pp -c not working" turned into a t.pl, using --lib
discussion, and the emails got pretty big, so I am here restarting with
this new subject name. I may have a definitive answer on one aspect of it.
To recap, assume a "mylib" directory underneath the current directory,
and the "--lib mylib" switch has to be in the pp line in order for
perl/pp to find it even given the "use lib mylib;" statement. This
assumes the t1.pl and the mylib\t1b.pl pasted below.
---------paste t1.pl
use warnings;
use strict;
use lib "mylib";
print "\n> t1: [EMAIL PROTECTED] = " . join(",\n ", @INC) . "\n";
require 't1b.pl';
print "\n> t1: \%INC = " . join(",\n ", values %INC) . "\n";
DoIt();
---------end paste t1.pl
---------paste mylib\t1b.pl
use warnings;
use strict;
sub DoIt() {
print "\nDid it (mylib/t1b.pl).\n"
}
1;
-----------end paste
The "Setting the Path at the Right Time" section of the "Intermediate
Perl" book discusses this sort of problem. Unfortunately, it does not
have the exact problem. However, it did lead me to make the
modification below. Namely, remove "use lib mylib" and instead do what
you see. The "use constant" happens at compile time, allowing
MY_LIB_DIR to also have a known value at compile time. The modification
works without --lib on the pp command line.
---------paste t1.pl modified
use warnings;
use strict;
use constant MY_LIB_DIR => "c:\\aaa\\mylib";
#use lib "mylib";
use lib MY_LIB_DIR;
print "\n> t1: [EMAIL PROTECTED] = " . join(",\n ", @INC) . "\n";
require 't1b.pl';
print "\n> t1: \%INC = " . join(",\n ", values %INC) . "\n";
DoIt();
---------end paste t1.pl modified
This still leaves the question of why the modification (or using the
--lib switch) needs to be done. I'll leave that to deeper minds, but
clearly it has to do with a compile time versus run time issue, and
therefore what is available to pp during the packing phase.
Thanks