You are probably more interested in reading Test::Output. This module is used to tie STDOUT and STDERR in Test::Output.

TIEHANDLE
The constructor for the class.

PRINT
This method is called each time STDERR or STDOUT are printed to.

PRINTF
This method is called each time STDERR or STDOUT are printed to with "printf".

FILENO

read
This function is used to return all output printed to STDOUT or STDERR. This code was taken from Test::Simple's TieOut.pm maintained Michael G Schwern. TieOut.pm was originally written by chromatic. Thanks for the idea and use of the code.