Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Best Way to Redirect STDERR to a Scalar

by BrowserUk (Pope)
on Sep 14, 2003 at 04:22 UTC ( #291344=note: print w/replies, xml ) Need Help??

in reply to Best Way to Redirect STDERR to a Scalar

I *think* the problem is that Devel::Peek is writing directly to the C file descriptor 2 (see perlfuc:fileno) rather than via a perl file handle, which basicaly means that any attempt to capture its output via tie is simply bypassed. Ie. The tie magic only works when you use the filehandle, which the perl internals don't.

Update: Forget the rest of this, it's! It couldn't work.

I have a feeling that it may be possible to capture the output by dupping the file descriptor. POSIX::dup2 might be one way, and re-opening files(dups) using the "&=2" version of the syntax might be another. I have had a play with the latter, without success, but I didn't spend much time on it.

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.

  • Comment on Re: Best Way to Redirect STDERR to a Scalar

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2017-12-15 01:15 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (415 votes). Check out past polls.