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


In reply to system, pipes, shell, quoting by superpete

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.