http://qs321.pair.com?node_id=503488

macrobat has asked for the wisdom of the Perl Monks concerning the following question:

In a module, I have a function, lcroak(), that redirects croak messages to a logfile. This is called selectively, so regular croak messages go to STDERR if the user wishes. It works, and it works the way I expect it, by closing and reopening STDERR with a previously-selected filename as an argument.

Problem: I can't get it to pass my lcroak.t test. If I call lcroak directly, then the test dies, as you'd expect when you call croak. But that's considered a failure by Test::Harness's prove utility.

Alternately, I can throw an eval loop around the lcroak call. But that redirects croak messages into $@, so subsequent tests, to see if my redirection worked, fail.

Anyone see a way around this?