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

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

Hello monks. Here is my situation. Currnet Code:
system("$program1 $file1 | $program2 -x -y | $program3 > $file2 2>/dev +/null");

I need to handle the possibility that the variables contain arbitrary weird characters (ANYTHING except / and nul).

The problem is that the shell is invoked, which messes things up. A previous posting here suggested that I use quotemeta (\Q, \E) , which appeared to work at first. Since then, however, I have done more rigorous testing, and for really weird filenames it fails.

Is there a standard way to deal with this, while keeping the convenience of the above line of code?

Is the right thing to cook up a function which takes a list of command lines, makes a bunch of pipes, and then forks off and exec's each "piece" of the pipeline (thereby avoiding the shell) ?? This seems like it would work but would be difficult to do in a "bulletproof" manner. Is there a standard module for this?

What should I do?

-Pete W