IO::Capture The IO::Capture Module defines an abstract base class that can be used to create any number of useful sub-classes that capture output being sent on a filehandle such as STDOUT or STDERR. Several modules come with the distribution that define sub- classes of IO::Capture to do just that. (I.e., capture STDOUT and STDERR) See the man page IO::Capture::Overview for a discussion of these modules and how to build a module to sub-class the B class yourself. # Some short examples to illustrate: # # Can be used to capture output from a command # use IO::Capture::Stdout; my $capture = IO::Capture::Stdout->new; $capture->start; system('wget', 'some_url.html'); $capture->stop; # # Or for module authors, to keep expected error messages # from clutering up your unit test output # print "1..2"; use IO::Capture::ErrorMessages; my $capture = IO::Capture::ErrorMessages->new; $capture->start; print force_an_error_test() ? "ok 1" : "not ok 1"; $capture->stop; print test_that_does_not() ? "ok 2" : "not ok 2";