Is there a way to print both on the "display" and in the file at the same time without repeating the "string" print code?
What I want to do:
if ($ofile) { open (FILE, '>>', "file"); print "Hello"
instead:
if ($ofile) { open (FILE, '>>', "file"); } print "Hello"; if ($ofile) { print FILE "Hello"; }
I tried googling search, but all I found was either or not two functions together.
Edit to add questions:
Then use IO :: Tee to create a new tee'd handle, and then select $ tee so that printing uses it by default. - Eric Strom
@EricStrom What do you understand when creating a new tee'd pen? Do you mean this Local::TeeOutput ? search.cpan.org/~mschilli/Log-Log4perl-1.34/lib/Log/Log4perl.pm
@EricStrom Do you have an example?
@EricStrom Local :: TeeOutput is not available in the default library for Strawberry Perl. Is there an alternative inside the default library?
source share