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

Re: Best Way to Redirect STDERR to a Scalar

by BrowserUk (Patriarch)
on Sep 14, 2003 at 04:22 UTC ( [id://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 bo..er..wrong! 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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-19 10:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found