Two red flags, and some yellow flags, as follows:

First red flag:

$b =~m/^\s*\w+\s+(\d+)\s+/o; my $b_pid = $1;
This code will get an incorrect $1 if the regex doesn't match. Never never Never look at $1 unless you've also tested the match.

Oh, and that applies a few lines later too. At least you're consistently wrong.

Second red flag:

my @args = ("kill", "-9", $2);
Never never never use kill -9 on a process, unless that process has resisted prior attempts to die via kill 1, 2, and 15.

First yellow flag, back to the earlier code snippet:

m/^\s*\w+\s+(\d+)\s+/o
What's the /o doing there? {insert cricket chirp sound effects} Right, nothing. Doesn't hurt it, but it absolutely doesn't help it either. In fact, you should remove it universally in this program (I just noticed it earlier too).

Second yellow flag... that sort screams for a Schwartzian Transform.

Third yellow flag: Perl has a kill function. Why not use it instead of system'ing out?

Conclusion: other than the bit about the Schwartzian Transform, the knowledge you are missing is contained within Learning Perl, which suggests that you read that book very soon.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.


In reply to Re: ppk by merlyn
in thread ppk by northwind

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.