# from A. Pagaltzis
# on Sunday 18 February 2007 07:45 am:
>Easily possible if you change your interface to something less
>magical-looking.
But then its not a unicorn anymore :'(
>Well, what does the module really do? It populates %INC with the
>proper bits for a given package name. That’s what I’d put in the
>name. Package::FakeIncEntry maybe.
True, that is what it does *under the hood*, but what it is used for is
more like Package::TODO or Package::Orphan. Naming it for an
implementation detail seems less findable.
> BEGIN {
> package Foo::Bar;
> use Package::FakeIncEntry;
I'm specifically trying to avoid labeling it BEGIN. The reason being
that it is less specific/too generic looking. Also, with the 'use
Unicorn' after the package declaration, the lines between the curlies
are no longer ready-to-go-be-in-a-file (plus, it embeds the magic
rather than stating it out front.)
use Package::Orphan sub {
package Foo::Bar;
...
__PACKAGE__;
};
Stands out more than just-another BEGIN block. Also, it allows one to
turn it off and see what breaks :-D. Plus, it would be easily editable
with PPI (or less.)
>Package/FakeIncEntry.pm is trivial:
>...
> sub import { my ( $p ) = caller; $INC{ $p } ||= _pkg2path $p }
Trivial, but the "Foo/Bar.pm" form is the key, and caller's filename is
the value. Implementation with the subref is just as trivial.
Thanks,
Eric
--
Entia non sunt multiplicanda praeter necessitatem.
--Occam's Razor
---------------------------------------------------
http://scratchcomputing.com
---------------------------------------------------