I highly doubt that. Very highly doubt it. Try using a data-dumping module to spit out exactly what you have. For example:

$ perl -MJSON -le '$output=`./asdf`; print encode_json([$output])' output to stderr ["output to stdout\n"] $ perl -MJSON -le '$output=`./asdf 2>&1`; print encode_json([$output]) +' ["output to stdout\noutput to stderr\n"]
or, if you don't have JSON:
$ perl -MData::Dumper -le '$output=`./asdf`;print Dumper $output' output to stderr $VAR1 = 'output to stdout '; $ perl -MData::Dumper -le '$output=`./asdf 2>&1`;print Dumper $output' $VAR1 = 'output to stdout output to stderr ';
You'll notice that if you omit the 2>&1, the stderr part shows up outside of the variable being dumped. What's more, it shows up first, which your original code shows is not what is happening for you. The only way that the stderr shows up after the stdout, given your asdf program, is if the stderr is successfully caught.

I will now ask you to take back you "bad design" call in your updated original node. It is based on your flawed testing, which your own node shows to be flawed. If you want to understand why the order of the output would be different if you weren't catching stderr, I would suggest a new root-level node for that. Not because we can't answer it here, but because I think you should go back to your test code and play with it for some time to see if you can figure it out yourself (with the help of google, that's fine) before asking.


In reply to Re^3: backticks fail to capture stderr even with explicit redirection by Tanktalus
in thread backticks fail to capture stderr even with explicit redirection by keithhanlan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.