in reply to Redirecting STDOUT to Variable - Not Having Much Luck
You are using backticks which capture program output and storing the result in $cmd. You never print that output therefore $output is empty.
use warnings; use strict; use IO::Scalar; my $output; tie (*STDOUT, 'IO::Scalar', \$output); # Use this to capture STDOUT print `echo foo`; untie *STDOUT; # Use this to return STDOUT to normal print "my output='$output'" __DATA__ my output='foo '
|
|---|