http://www.perlmonks.org?node_id=712873

devnul has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I'm really at a loss on the best way to approach this silly problem. I have a command-line program that does not properly generate exit codes (the source code for which is unavailable, so it can't be fixed).

Over the years, I've grown accustomed to using this nomenclature when executing an external command:
open(PIPE, '-|', $somecommand, $arg1, $arg2, ..., $arg(N), $filanem);
(where $filename is usually something grabbed from readdir, so it may contain spaces, etc)..

Unfortunately, the piece of data I need to grab to see if the command has failed is being sent to STDERR, not STDOUT.

For the life of me, I cannot seem to find a way to get the 3+argument version of open to give me what is going to STDOUT.

Alternatively, I am happy to go back to the 2-argument version, but how can I ensure that the filename I am passing in gets through the shell ok?...

...I've been up all night, so I apologize if this seems silly...

- dEvNuL