http://www.perlmonks.org?node_id=416624

crenz has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,

I need to debug a badly written "everything-in-one-script" kind of CGI application. For that, I need to log all the input and output. I already managed to log the output by inserting something like this at the top of the application:

BEGIN { my $tee = new IO::Tee(\*STDOUT, ">logfile"); select($tee); }

I'd like to do something similar with STDIN. IO::Tee can also handle reading, but I don't know how to "replace" the current STDIN with $tee_in. I am probably looking for something like *STDIN = $tee (which of course won't work).