http://qs1969.pair.com?node_id=490307

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

Dear Perl Monks:

I want to redirect both STDOUT and Error messages to a file and also display in the screen, when I run a perl script.
I know that using tee.exe will help in gettting this done. But this operation will not return the exit code of the script.
perl -w sample1.pl 2>&1 | tee stdout.txt
So I tried to do this.
perl -w sample1.pl > stdout.txt 2>&1
But it only redirects the STDOUT and error messages to a file (Not printing in the screen).
Does any body know an alternative way of doing this w.o using tee.exe?

------------------- UPDATE -----------------------
Note: I am using a Windows XP/2000 machine!
-----------------------------------------------------
Thanks!