Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Printing both to console and File

by 1nickt (Monsignor)
on Apr 17, 2017 at 11:56 UTC ( #1188130=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1188130]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2018-08-18 12:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:









    Results (185 votes). Check out past polls.

    Notices?