Okay I stand corrected in that order matters. That said, I honestly can't remember ever seeing 2>&1 not coming at the end of the command line, probably because doing so seems to indicate that it won't be captured to STDOUT as one desires.
You're entirely correct that wanting to redirect both STDOUT and STDERR is the most common case, and for that one you do indeed need the 2>&1 at the end.
However that does not appear to be what the OP wants; Unless I misread the question, he wants to capture STDERR output using the backticks, while having STDOUT going to the file. For that you need the reverse otder.
With all of the foregoing comments by both you and me in mind, I think you're first comment implies that it must come first in order to be captured.
... in order to be captured by the backticks instead of going to the file with STDOUT.
Also, it is possible that setting $| = 1; might alter the output ordering.
I think you're right about that.
Are you posting in the right place? Check out Where do I post X? to know for sure.
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
Want more info? How to link or
or How to display code and escape characters
are good places to start.