NAME
CaptureOutput - temporarily capture output from a filehandle
SYNOPSIS
print STDERR "before capturing\n";
my $recorder = capture(*STDERR); # start capturing
print STDERR "during capturing\n";
my $recd_output = $recorder->(); # stop & get recording
print STDERR "after capturing\n";
print "Recorded output = $recd_output";
DESCRIPTION
This module exports a single function capture that allows you to temporarily capture output from a given filehandle. The function returns an anonymous function that can be used to restore the filehandle to its previous condition and return any captured output.
For example, the output of the code in the Synopsis is as follows:
before redirection
after redirection
Saved output = during redirection
AUTHOR
Tom Moertel (tom@moertel.com)
COPYRIGHT and LICENSE
Copyright (c) 2004-05 by Thomas G Moertel. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.