use File::Spec::Functions; sub use { my($pkg, @args) = @_; my(@dirs, $file) = split '::', $pkg; my $path = catfile @dirs, "$file.pm"; return if exists $INC{$path}; my $fullpath = catfile( (grep { -f cafile($_, $path) } @INC)[0], $path ); my $code = IO::File->new($fullpath) or die "$!"; $INC{$path} = $fullpath; eval $code->getlines; $file->import(@args); }