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


in reply to How to display the .pl process in command line

Well, I have a couple recommendations. For one, please organize your code. Remember DRY(Don't Repeat Yourself), there is a lot of code duplication in that snippet. And also think about logically grouping your code. Secondly(and most importantly), I think you want IO::Tee.

use IO::Tee; my $out_handles = new IO::Tee(\*STDOUT, new IO::File('>random_file.txt +')); print $out_handles "*Hey Buddy*\n"; print $out_handles "*I'm on your screen and your file!*\n";

So, essentially, IO::Tee allows you to write to multiple file handles simultaneously.

You could use a second print statement with just a string to accomplish the same result. Or select. Plus a bunch I can't think of right now. Always a lot of choices.