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
From:
rgarciasuarez
Date:
September 4, 2001 01:50
Subject:
Re: [PATCH] put useful info in %INC for files loaded by a hook in @INC
Message ID:
slrn9p95e0.k1p.rgarciasuarez@rafael.kazibao.net
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/Foo.pm>, 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/Bar.pm 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/Bar.pm from it
    3. if this fails, walk over the whole @INC to try to find Foo/Bar.pm
       (that's the questionable part)
    4. if this also fails, die.

The problem is : /loader/0x81095c8/Foo/Bar.pm 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/Bar.pm". 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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About