eval <<"END"; package $calling_package; use Test::More @test_more_imports; use Test::Exception @test_exception_imports; use Test::Differences @test_differences_imports; END if ( my $error = $@ ) { ... }