Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
When we say "$manager->start and next;" , doesn't what is below this statement (rest of the for loop that is) get skipped completely?

The and isn't just a "do this then this", it's a shortcut operator. If the $manager->start evaluates to something true, it does the next, but otherwise it doesn't.

In the particular case of Parallel::ForkManager, the ->start method returns values just like fork does; in the parent, it returns the pid of the child (which is a positive integer, and thus true), and in the child, it returns 0 (which is false).

So, the result is that in the parent process, the next happens, and it goes around and spawns off the next one (which is what you want the parent to do). In the child, since the ->start returns a false value, the and isn't followed, and it goes ahead and does the bits of actual work. The child does its thing (with system in this case), and then calls the ->finish method, which is equivalent to exit, so the child doesn't go back to the top of the loop and try spawning off more children (that's the parent's job).


In reply to Re^2: Introduction to Parallel::ForkManager by fullermd
in thread Introduction to Parallel::ForkManager by biosysadmin

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    [Corion]: marto: Redoing something on new infrastructure sounds fun. At least you can reuse your previous experience :)
    [marto]: I'm looking forwads to it. The video sources are dying, and they don't have the hardware to play them back (old tape formats, not just VHS + Laserdisc etc)
    [marto]: I'll be interested to see what difference in terms of file size/quality the new codecs make. I enjoy working on things like this, so that's a bonus
    [Corion]: Ah, cool! So it's not an inhouse youtube but for a wider consumption
    [marto]: last time it was IE6 clients, now they're on 11, so more scope there also, in terms of UI and playback
    [marto]: in house as in Company network, not internet connected (power stations and the corporate HQs)
    [Discipulus]: new Monsignor party! free beverages and pizza for all you monks! and a big thanks for the patience you deserved me during these years
    [marto]: congrats Discipulus
    [Discipulus]: only 4k points to sundial's level ..;=)
    [Corion]: Yay Discipulus ;)

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (11)
    As of 2017-07-28 09:21 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      I came, I saw, I ...
























      Results (425 votes). Check out past polls.