http://www.perlmonks.org?node_id=1105529


in reply to capturing stderr of echo piped to a file

Here is how I've done it in test files:

# Capture any STDERR output my $stderr = ''; local *STDERR; open STDERR, '>', \$stderr;
I can't remember where I first saw that, but I've kept it handy ever since.

You must always remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.