Browse - Programming Tips - How do I redirect/capture STDOUT to a $variable ?
Q. How do I redirect/capture STDOUT to a $variable ?
A. There are various ways. But I like this the best.
Make a subroutine that declares *STDOUT has a local like this:
open(STDOUT, '>', \$v);
The scope of the local is the inside of the brace brackets so there
is no need to close, etc.