As others have said, use top to see if you're running out of memory. That seems the most likely culprit.

If the amount of output from your programs is large, an improvement that would reduce memory usage would be to change the child code to:

unless ($cpid[$i]) { exec 'perl',$_ or die "exec error: $!\n"; }
(You might have to play around with file descriptors a little to make this work just right). Using backticks causes another fork to be done, with the resulting parent reading the child's output, storing it into a scalar variable, then when the child exits prints the results. Using exec instead saves a fork, and instead of reading all of the input into a scalar variable, just lets the child write to stdout directly.

Also, adding better error checking, along with use strict and the -w flag might help you locate errors that are making your program behave in unexpected ways.

How many programs are listed in @gets?


In reply to Re: Code and Process Efficency by sgifford
in thread Code and Process Efficency by mcogan1966

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.