Re: "Simple" Question

Marc Langheinrich (marclang@cs.washington.edu)
Fri, 2 May 1997 16:53:54 -0700 (PDT)


On Fri, 2 May 1997, Bill Melvin wrote:
> Would the $INC{$key} for the $key "LWP/Protocol.pm" be 0 if the file wasnt
> found??
> I think I looped through %INC correctly so Im still stumped.
You did the loop ok, the problem is that the module you're looking for 
(LWP::Protocol::http) doesn't get included until the LWP::Protocol 
modules needs an implementation for that particular scheme. So, at the 
time you're calling &getprint, there wasn't any need yet for loading 
LWP::Protocol::http -- that's why it's not in %INC...

The code that does the loading is LWP::Protocol::implementor. There it 
builds the module name and then uses 'eval' in order to load the 
implementation module:

sub implementor
{
	...
    $ic = "LWP::Protocol::$scheme";  # default location
	...
        my $package = "$ic.pm"; 
        $package =~ s|::|/|g;  # Unix specific?? 
        eval { require $package }; 
	...
}

Maybe the substitution there (s|::|/|g) isn't portable to your system?! 
I actually don't know why a simple

	eval "require $ic;"

wouldn't work. (but then again, I didn't write the package, maybe 
there was a reason...) Maybe you want to change that line and see if that 
works for you...


*HTH*

Marc
---
Marc Langheinrich                  Department of Computer Science & Engr.
office phone: (206) 543-5129       University of Washington, Box 352350, 
email: marclang@cs.washington.edu  Seattle, WA 98195-2350, USA
www: http://www.cs.washington.edu/homes/marclang/