Re: Can Perl redirect STDOUT to file AND to command window?



rcm...@xxxxxxxxx wrote:
> I have been searching for a way to redirect STDOUT to a file and to
> the command window at the same time. So far, no luck - is this possible?

Sure. use IO::Tee (http://search.cpan.org/~kenshan/IO-Tee-0.64/Tee.pm)

Or, if you want to get REALLY cool, use Log::Dispatch and attach
handlers for file and screen (and you can fire the handlers based on
the log level of the message, so you can fire one or both handlers
based on the level you stipulate). I use Log::Dispatch for ALL of my
process messages (I rarely use "print" statements except for trivial
code).

.



Relevant Pages

  • Re: Can I create my own User events?
    ... For instance, if I execute a function, then I can write a line of code to execute my own specialized event. ... When the event source wants to fire the event, it calls the OnHappens with some arguments to be casted along with the event. ... The OnHappens function enumerates the handlers list and invokes each one with the appropriate set of arguments. ...
    (microsoft.public.scripting.jscript)
  • Re: DataGrid does not recognize Select, Edit, etc buttons when EnableViewState = False
    ... generated event handlers have been known to quit. ... something whacks them ... The event won't FIRE?? ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Set / Clear and restore control event handlers
    ... code which would cause the control to fire an event. ... about handlers for a particular control, remove the handlers, do some code and restore the cached event handlers in VB.NET. ... I am looking for a general method which would take into account that I would not know what to use for Addhandler and RemoveHandler so I am looking for a method to enumerate the "added" handlers and then cache the info, do a remove and when asked reset using AddHandler. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Set / Clear and restore control event handlers
    ... code which would cause the control to fire an event. ... AddHandler .... ... about handlers for a particular control, remove the handlers, do some code and restore the cached event handlers in VB.NET. ...
    (microsoft.public.dotnet.languages.vb)