Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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

by shenme (Priest)
on Sep 13, 2003 at 23:57 UTC ( #291315=note: print w/replies, xml ) Need Help??

in reply to Re: Best Way to Redirect STDERR to a Scalar
in thread Best Way to Redirect STDERR to a Scalar

Unfortunately Tie::STDERR won't do what's needed.   There's this note in the POD:
However, if you run external command (system, ``), stderr output from that process won't be caught.   It is because we tie Perl's STDERR fileglob, not the external filehandle.
(grumble - sounded wonderful tho)
  • Comment on Re: Re: Best Way to Redirect STDERR to a Scalar

Replies are listed 'Best First'.
Re: Re: Re: Best Way to Redirect STDERR to a Scalar
by davido (Archbishop) on Sep 14, 2003 at 01:06 UTC
    I don't know that it's correct or safe to jump to the conclusion that Tie::STDERR won't do what's needed, as the OP didn't specify in his original post that he was trying to catch errors that come from executing external commands.

    Tie::STDERR will allow you to redirect any errors that come from Perl or Perl commands, but not from external (such as system() or `` backticks). It will even catch Perl's compiler errors, though as the POD states, the errors that it reports from the compiler aren't what you might expect to see.

    So if you're trying to redirect the output from any Perl-generated errors, or errors that you generate internally in your script, Tie::STDOUT works great. But if you want to redirect external command errors, you'll have to dig deeper.


    "If I had my life to do over again, I'd be a plumber." -- Albert Einstein

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2018-01-24 04:03 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (255 votes). Check out past polls.