The C Module defines an abstract base class that can be used to build modules that capture output being sent on a filehandle such as STDOUT or STDERR. Several modules that come with the distribution, do just that. (I.e., Capture STDOUT and STDERR) See L for a discussion of these modules and examples of how to build a module to sub-class from C yourself. If after reading the overview, you would like to build a class from C, look here for details on the internals. WWW: https://metacpan.org/release/IO-Capture