On 07/19/2015 07:00 AM, Zefram wrote:
James E Keenan wrote:
That leaves only the problem of capturing STDOUT
close(STDOUT);
open(STDOUT, ">", \$captured_stdout);
-zefram
Thanks for the suggestions. I had looked at 'perldoc -f select' but
couldn't quite figure out the sequence of commands. This got me much
closer. Here's what I currently have, which is DWIMming:
sub _run_for_verbose {
my $coderef = shift;
my $stdout;
my $oldfh = select(STDOUT);
local $| = 1;
close STDOUT;
open STDOUT, '>', \$stdout;
&$coderef;
close STDOUT;
return $stdout;
}
Called like:
is(_run_for_verbose(sub {@created = mkpath($dir, 1)}),
"mkdir $base\nmkdir $dir\n",
'mkpath verbose (old style 1)'
);
Thank you very much.
Jim Keenan