Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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 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.


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (14)
As of 2014-07-22 15:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (117 votes), past polls