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


in reply to Printing both to console and File

The doc for IO::Tee indicates (unsurprisingly) that you need to pass two filehandles to the constructor, not construct two instances:

use IO::Tee; $tee = IO::Tee->new($handle1, $handle2); print $tee "foo", "bar";

For another approach see Log::Any, Log::Any::Adapter, Log::Any::Adapter::Dispatch.

Hope this helps!


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: Printing both to console and File
by perluser455 (Initiate) on May 17, 2017 at 10:15 UTC
    Thanks for the reply, but Can you Please let me know how to pass stdout/stderr to filehandles when declared as use IO::Tee; $tee = IO::Tee->new($handle1, $handle2);

      It so happens that the example that contains the answer to your question is in the example section of IO::Tee's documentation.

      Edit: wait, you already use the \*STDOUT notation in your OP, I must be misunderstanding your question.