use strict; require lib; lib::->import( sub { my ($self, $filename) = @_; lib::->unimport($self); # Enable require below. require Benchmark; # Some module that exists, just as demo. lib::->import($self); # Put it back in business. my $rc = 1; return sub { $_ = 1 if $rc; return $rc--; }; } ); print "Trying to require some modules that doesn't exist, "; require This::Does::Not::Exist; require Cwd; require This::Does::Not::Exist::Either; print "and it worked.\n"; __END__ Trying to require some modules that doesn't exist, and it worked.