Could you show a Short, Self-Contained, Correct Example, that is, a short piece of example code that shows the problem, with short sample input and the expected output you want to get, and the actual output, including any error messages, each inside <code> tags?

Going off of your description, I would recommend a module like IPC::System::Simple, its systemx and capturex functions avoid the shell*, and as LanX said, you can provide the commands to be executed in Perl constructs like q{}. Note how in the following, I don't have to escape quotes or $ (it's printing the $$ variable).

use warnings; use strict; use IPC::System::Simple qw/systemx capturex/; systemx('perl', '-e', q{print "'$$'\n"} ); my $o = capturex('perl', '-e', q{print "'$$'"} ); print "<$o>\n";

I wrote at length about the issues with running external commands here.

* Update: Note this also means there won't be any shell redirections or piping available. If you need this, please show and example of the commands you're trying to run, often there is a way to work around it e.g. with capturex, temporary files, or a different module like IPC::Run3 or IPC::Run.


In reply to Re: awk cmd in perl by haukex
in thread awk cmd in perl by blur

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.