The code you provided seems to have a few syntax errors (e.g., /usr/local/bin/perl needs the slashes to be escaped, and the regex beginning with sh is never terminated), but I've tried to clean it up as well as I could. This program is not equivalent to your Unix grep/awk pipeline, but I've tried to keep the meaning of your Perl code approximately the same.
#!/usr/local/bin/perl use strict; use warnings; open(OF,">outr") || die "File not opening outr: $!\n"; foreach (`ps -ef | grep jones` =~ /[^\n]*\n/g) { next if m!/usr/local/bin/perl ps1$! or /sh -c ps -ef \| grep jones > + outr$/; print OF; } close(OF);
Hopefully this does about what you want. A couple of points about it:

-- Mike

--
just,my${.02}


In reply to Re: Trying to grab process output. by thelenm
in thread Trying to grab process output. 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.