in reply to Re: Print to the screen and a log at the same time?
in thread Print to the screen and a log at the same time?

Why not

sub _print { print $msg, @_; print LOG $msg, @_; } _print("hello"); _print("world");

That way, you can print lists, and $, and $\ will be obeyed. OTOH, the simplest solution is probably the following:

use IO::Tee (); my $fh_out = IO::Tee->new(\*STDOUT, \*LOG); select($fh_out); print("hello"); print("world");

But there are problems with using select.