sub worker { local( *STDOUT, *STDERR ); open STDOUT, '>', 'my.log' or die $!; open STDERR, '>&STDOUT' or die $!; unmodifiable(); ## call the code that produces the output; it'll end up in my.log ## the effects of the redirection get cleaned up automatically when the worker ends. }