With a command as complex as you showed, I would very much recommend doing as much of it in Perl as possible instead of shelling out - there are potential security issues, quoting challenges, etc. with shelling out. I wrote about that at length here (with code examples). In particular, both fgrep and awk can be replaced by pure Perl. Instead of ps, you might try Proc::ProcessTable. That leaves only xl and sockstat. If you want to run those external processes and need to feed something to their STDIN, I'd recommend IPC::Run3. Otherwise, if you just want a simple replacement for backticks, there's capturex from IPC::System::Simple.


In reply to Re: system commands/shell and perl variables. by haukex
in thread system commands/shell and perl variables. by Anonymous Monk

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.