in reply to printing and logging to a file

You have plenty of good suggestions already, but here is another one. You could write Tie::Handle::StdOutAndFile. You can visit our Tutorials section, and read The tie()s That Bind or perltie to find out how to write a tie interface. The module'd be used something like
{ use Tie::Handle::StdOutAndFile; local *STDOUT; tie(*STDOUT,'Tie::Handle::StdOutAndFile','file.txt') or die "Aaah $ +!\n"; print "whatever"; }
Then when you print, "whatever" would end up in file.txt and STDOUT. Here are two examples of TIEHANDLE Re: Line Numbers Re: monitor STDOUT in scalar. Also, if you choose to implement a tie interface, be sure to advice given by japhy at Tie-dy up our namespaces.
That is all.

 
______crazyinsomniac_____________________________
Of all the things I've lost, I miss my mind the most.
perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"