use warnings;
use strict;
use Mail::Sender;
use IO::Scalar;
my $output;
my $date = '31Jul200';
my $logfile = "d:\\log\\$date.log";
my $elogfile = "d:\\log\\exported\\$date.elog";
tie (*STDOUT, 'IO::Scalar', \$output); # Use this to capture STDOUT
my $cmd = `fw logexport -i $logfile -o $elogfile -r 1000 -n`;
untie *STDOUT; # Use this to return STDOUT to normal
print "my output='$output'"
####
D:\scripts>perl temp.pl
Failed to open file 'd:\log\31Jul200.log': The system cannot find the
file specified. untie attempted while 1 inner
references still exist at temp.pl line 14. Use of
uninitialized value in concatenation (.) or string at temp.pl line 15.
my output=''
####
use warnings;
use strict;
use IO::Capture::Stdout;
my $capture = IO::Capture::Stdout->new();
my $date = '31Jul200';
my $logfile = "d:\\log\\$date.log";
my $elogfile = "d:\\log\\exported\\$date.elog";
$capture->start();
my $cmd = `fw logexport -i $logfile -o $elogfile -r 1000 -n`;
$capture->stop();
my $line = $capture->read;
print "$line";
####
D:\scripts>perl temp.pl
Failed to open file 'd:\log\31Jul200.log': The system cannot find the
file specified. Error retreaving captured text in
IO::Capture::Stdout at temp.pl line 16
Use of uninitialized value in string at temp.pl line 19.