sub init { my $pkg = shift; my $proto = shift || $config->protocol(); no strict 'refs'; eval "require Bot::Protocol::$proto"; if($@) { croak "Failed to load $proto.\n"; } } #### # in the main my $pkg = shift; no strict 'refs'; eval "require $pkg"; if($@) { croak "Failed to load $pkg: $@\n"; } print foobar(); #### # in Foo.pm package Foo; use strict; use Exporter; use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @EXPORT = qw(foobar); sub foobar { return "Foo!"; } 1;