Hehe, it does seem kind of looney, doesn't it?
In a broad scope (see last e-mail which explains the benefits we gain), it
is solving a real problem.
For example, which might be efficient enough...
# ...
my $MOD = SomeMod;
sub handler()
{
# ...
if ( $INC{$MOD} ne $ENV{'LIBDIR'}/$MOD )
{
delete $INC{$MOD};
}
require $MOD;
# ...
}
# ...
Might as well just make a new sub to replace require()...
sub librequire() {
my ($filename) = @_;
if (exists $INC{$filename}) {
return 1 if ( $INC{$filename} =~ m#^$ENV{'LIBDIR'}/# );
}
my ($realfilename,$result);
$realfilename = "$ENV{'LIBDIR'}/$filename";
if (-f $realfilename) {
$INC{$filename} = $realfilename;
$result = do $realfilename;
}
if ($@) {
$INC{$filename} = undef;
die $@;
} elsif (!$result) {
delete $INC{$filename};
die "$filename did not return true value";
} else {
return $result;
}
}
That would allow me to simply say "librequire Some::Mod" rather than
"require Some::Mod" and have the same effect, allowing us to defeat the
cache when necessary, always getting the right module, whether it's provided
by cache or not.
--
Devin Teske
----- Original Message -----
From: "Brad Van Sickle" <bvs7...@gmail.com>
To: "Adam Prime" <adam.pr...@utoronto.ca>
Cc: "Alan Young" <alansyoung...@gmail.com>; "Devin Teske"
<dte...@vicor.com>; "Michael Peters" <mpet...@plusthree.com>;
<modperl@perl.apache.org>
Sent: Tuesday, October 20, 2009 4:22 PM
Subject: Re: Custom INC per-directory
I don't know the specifics of your project so it's quite possible that I'm
missing something, but this all seems like an incredibly bad idea.
Sure you can knock some cringe inducing code together and get it to
technically work, but the very fact that you need to resort to these sort
of unorthodox methods should be a hint that you might have something wrong
in your systems or software design.
Again, I lack a full perspective here and maybe you have good reasons, but
this sounds like a problem screaming to be solved in conception, not in
implementation.
Adam Prime wrote:
Alan Young wrote:
Wouldn't using the Parent option (
http://perl.apache.org/docs/2.0/user/config/config.html#C_Parent_ )
work better for what you're trying to do?
Parents requires vhosts, which he said he doesn't want to use.
Adam