in reply to backticks are echoing stderr
You can find more information on the backticks from "perldoc perlop" (look for "qx"). Quote: "The collected standard output of the command is returned; standard error is unaffected." It then goes on to give a bunch of examples, including the answer to your question.
I think there are a few reasons for this behaviour. First off, you generally don't want to hide the stderr. If there is an error in the command you're running, you probably DO want it to leak through to the person running the script - it may have very useful information as to why your code is acting funny. Second, it serves as a reminder to us, the perl developers, that there's really nothing we can do to block all output. If an application really wants to, it can open a brand new filehandle to the current (pseudo-)terminal device, which seems really easy on Linux - get your parent's pid, and open /proc/$ppid/fd/1 for writing:
It may take a bit more work on other platforms, but I'm sure that most unixy platforms will allow you to find the current terminal and write to it (barring a change of session ID or UID). Of course, this is fairly pathological, and I doubt Rational would do this, but it's still something to note.$ perl -le 'open my $fh, ">", "/proc/" . getppid . "/fd/1" or die $!;p +rint $fh "<Nelson>Ha ha!</Nelson>"' > /dev/null 2> /dev/null <Nelson>Ha ha!</Nelson>
|
|---|