use warnings; use strict; use Test::More tests => 3; use Test::Exception; ok(require('x.pm'), 'loaded'); throws_ok( sub { killer () }, qr/hasta la vista baby/, q{Expected killer to die}); BEGIN { no strict 'refs'; no warnings; *CORE::GLOBAL::exit = sub { die "exited with code ", $_[0] || 0; }; } throws_ok( sub { exiter () }, qr/exited with code 42/, q{killer exited});