http://www.perlmonks.org?node_id=603267


in reply to Apply a source filter to all modules to be loaded?

This is crazy talk, but that's not stopping Perl from having it, see require:

sub my_own_loader { my ($self,$file) = @_; open my $fh, "<", "my/private/dir/$file" or return; $fh }; BEGIN { unshift @INC, \&my_own_loader; }; use Foo::Bar; use The::Net;

You might also want to look at Filter::Simple, but please realize that source filtering isn't a sane practice :)