in reply to capture STDOUT when some jerk opened STDOUT to /dev/tty

Capture::Tiny seems to handle it fine.

use Capture::Tiny qw( capture_stdout ); open STDOUT, '>/dev/tty' or die $!; my $output = capture_stdout { print "Hello world!\n"; }; print "<<<$output>>>\n";

...the output...

<<<Hello world! >>>

(as expected)

Update: ww has kindly reminded me that this is probably not a solution when you need to capture output of an external script. Apologies... and good luck! ;)


Dave