Hello,
I'm trying to make my script more efficient so I decided to learn how to use fork.
This question is more on how to write it nice and clean
I have about 13 different calls that create files. Those calls are not depended and they can run parallel:
create_file('A'); create_file('B'); create_file('C'); create_file('D'); create_file('E'); ...
I understand how to create a fork and how to check if there is one and why it is important to use the wait function.
But I don't know how to make it look nice, clean and readable. Should I create a special function which will be called every time I need to create X (for example 5) forks? How should I keep track of those forks? If for example, I have 13 things I can run parallel, should I use 13 forks (running on a strong machine)? Meaning how to determine how many forks to use?
I would really love to see some real example with for example 13 different calls.

In reply to Learning to use fork() by ovedpo15

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.