package MyApp::Log; my $log; sub enable { ... $log = MyApp::Log->new($context); tie *STDERR, 'MyApp::Log::STDERR'; ... } { package MyApp::Log::STDERR; sub TIEHANDLE { my $class = shift; bless {}, $class; } sub PRINT { my $self = shift; $log->die(join '', @_); } }