in reply to Loading a Module from a Variable

If I understand correctly what you want, then you may exploit the possibility of putting code into @INC (see perldoc -f require):
#!/usr/bin/perl use strict; use warnings; use lib sub { my $file=pop; return undef unless $file eq 'Foo/Bar.pm'; open my $fh, '<', \<<".EOM" or die $!; package Foo::Bar; use strict; use warnings; sub new { "Hello World!\n", "this is ", __PACKAGE__, "\n"; } 1; .EOM $fh; }; use Foo::Bar; print Foo::Bar->new; __END__