in reply to capture STDOUT when some jerk opened STDOUT to /dev/tty
Why not fake modifying the script by using do?
select MYSTDOUT; # use *MYSTDOUT instead of STDOUT for output # so all his reopening manipulates the wrong filehandle # Run the original script in our interpreter do 'original_script.pl' or die;
Update: Also, you should be able to combine this with davido's recommendation of Capture::Tiny to do the (re)capturing before the main script starts.
Update 2: No, it's unlikely. The Capture::Tiny documentation says:
Attempting to modify STDIN, STDOUT or STDERR during capture or tee is almost certainly going to cause problems. Don't do that.
|
---|
In Section
Seekers of Perl Wisdom