This message is one of several periodic postings to DevShed's Perl Forum intended to make it easier for Perl programmers to find answers to common questions. The core of this message represents an excerpt from the documentation provided with every Standard Distribution of Perl.

---------------------------------------------How can I capture STDERR from an external command?

This fails because the open() makes STDERR go to where STDOUT was going at
the time of the open(). The backticks then make STDOUT go to a string, but
don't change STDERR (which still goes to the old STDOUT).

Note that you *must* use Bourne shell (sh(1)) redirection syntax in
backticks, not csh(1)! Details on why Perl's system() and backtick and
pipe opens all use the Bourne shell are in http://www.perl.com/CPAN/doc/FMTEYEW...sus/csh.whynot . To capture a
command's STDERR and STDOUT together:

The first command sends both standard out and standard error to the
temporary file. The second command sends only the old standard output
there, and the old standard error shows up on the old standard out.
---------------------------------------------

Documents such as this have been called "Answers to Frequently Asked Questions" or FAQ for short. They serve to reduce the volume of redundant traffic on this bulletin board by providing quality answers to questions that keep comming up. If you find errors or other problems with these postings please send corrections or comments to the posting email address.

------------------
Written by Anonym0us, inspired by the original PerlFAQ Server.