develooper Front page | perl.perl5.porters | Postings from September 2001

Re: [PATCH] put useful info in %INC for files loaded by a hook in @INC

Thread Previous | Thread Next
September 4, 2001 01:50
Re: [PATCH] put useful info in %INC for files loaded by a hook in @INC
Message ID:
Benjamin Goldberg wrote :
} > +If the file was loaded via a hook (see L<perlfunc/require> for a
} > +description of these hooks), a fake filename is inserted into %INC.
} > +It looks like F</loader/0x81095c8/>, where the hexadecimal
} > +number corresponds to the reference that was put in @INC.
} I suppose this is a silly question, but why not simply put the code ref
} [or arrayref or objectref] itself into %INC ?  Would this make it much
} easier to patch the other stuff [AutoLoader, DynaLoader] to work with
} hooks in @INC ?

I didn't thought about this solution.

Here's what I had in mind :

When a file /loader/0x81095c8/Foo/ is require'd, perl should :
    1. Drop /loader/0x81095c8/ from the filename
    2. look for a hook at address 0x81095c8 in @INC and try to load
       Foo/ from it
    3. if this fails, walk over the whole @INC to try to find Foo/
       (that's the questionable part)
    4. if this also fails, die.

The problem is : /loader/0x81095c8/Foo/ is constructed from the
value in %INC corresponding to a module previously loaded via this hook.
This construction will stringify the %INC value and will end with
something like "CODE(0x81095c8)Foo/". This will not solve the
problem unless we patch all modules out there that mess up with %INC in
specific AUTOLOAD routines (Gisle has given an example).

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About