http://qs321.pair.com?node_id=192635


in reply to Building a Simple Perl Module Database

Did you know you can put coderefs in @INC?
#!/usr/bin/perl -wl BEGIN { unshift @INC, \&magic_inc; sub magic_inc { print $_[1]; my $i; return \&magic_load if $_[1] eq "Foo/Bar.pm"; } my @src = ("print q(Foo::Bar loaded!);", "1;"); sub magic_load { return defined($_ = shift @src); } } use strict; use Data::Dumper; use Foo::Bar;
The interface is somewhat obscure, but this close to the guts, you have to expect it.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Coderefs in @INC (was: Building a Simple Perl Module Database)
by djantzen (Priest) on Aug 26, 2002 at 00:05 UTC