NAME
Mnet::Tee - Redirect stdout and stderr to a file
SYNOPSIS
# use this module on it's own
use Mnet::Tee;
Mnet::Tee::file($file);
# or use with command line options
use Mnet::Tee;
use Mnet::Opts::Cli;
my $cli = Mnet::Opts::Cli->new;
DESCRIPTION
This module captures all stdout and stderr output from an executing script and saves that output to the specified file. Be sure to call Mnet::Tee::file() or parse cli options before generating any other output.
The variables stdout and stderr can be imported from this module to use for output that should not be captured by the Mnet::Tee module. The pause and unpause functions in this module can be used for this purpose also.
Note that output captured by this module is stored in memory. That could be a problem for scripts that generate gigabytes of stdout and/or stderr output.
The perl tie command is used to implement the functionality of this module.
file
Mnet::Tee::file($file)
The function can be used to write output to the specified file, including all prior output. The script will abort if unable to open the new file.