I have a (probably simple) question about invoking system commands with perl. I know about the `command` operators, but the question involves somewhat of syntax/parsing.

I need to call a perl script test.pl with two arguments. The arguments are variables, and I need them interpolated. The second argument I need to actually combine two variables with a '\' (it's a directory path), and have them, of course, interpolated as well.

Now, I can imagine that
`perl test.pl "$var1" "$var2\\$var3"`
won't work (and is quite atrocious). I tested several variants (making a temporary variable) and none seemed to work (let it be noted that I took the quotes out, and made a test.pl file to print its given arguments; on several tests I got a 'Bad command/filename, etc' error, and several nothing happened at all, save a short pause).

WHAT WILL WORK?


In reply to A question with commands by dimmesdale

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.