Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: Open pipe to a function?

by Sprad (Hermit)
on Dec 10, 2003 at 21:44 UTC ( [id://313888]=note: print w/replies, xml ) Need Help??


in reply to Re: Open pipe to a function?
in thread Open pipe to a function?

I can't just redirect it, because I also want to see it at runtime.

---
A fair fight is a sign of poor planning.

Replies are listed 'Best First'.
Re: Re: Re: Open pipe to a function?
by hardburn (Abbot) on Dec 10, 2003 at 21:48 UTC

    You could probably do some tricks with IO::Multiplex. Just save the orginal filehandle like this:

    my $old_stderr = *STDERR;

    And then reopen STDERR with IO::Multiplex with $old_stderr and a filehandle to the log file.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    : () { :|:& };:

    Note: All code is untested, unless otherwise stated

Re: Re: Re: Open pipe to a function?
by tcf22 (Priest) on Dec 10, 2003 at 21:59 UTC
    How about
    use IO::Tee; open(ERRLOG, '>error.txt'); my $tee = new IO::Tee(\*STDOUT, \*ERRLOG); *STDERR = $tee;

    - Tom

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://313888]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-24 14:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found