The documentation for open() perlfunc:open has an example of saving, redirecting, and restoring STDOUT and STDERR that you might find helpful.
In reply to Re: redirecting STDERR, then back again
by danger
in thread redirecting STDERR, then back again
by melguin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |