Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
hi all

These days I am learning perl by writing simple perl programs. I have done lot of system side programing using fork in 'C' language. So I have enough knowledge on fork and its behaviour.
I am wondering the behaviour of fork, when I use it with perl. I might have not understood the fork concepts properly in perl.
definitely monks can explain me better. Here is my code

fork || print for split (//, "a" x 10);
Output :-
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +aaaaaaaaaa aaaaaaaaa1a11aaa1aaa1aaa11a1aaaaaa111a1a11a11a1a111aaa1aaaaaaaaaaaaaaa +aaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +aaaaaaaaaa aaaaaaaaaaaaaaaaaa1aaa1a1a1aaaaaaaaaaaa11aaaaaa1a111a1a1a1aaa11aa1a11a +111a111aaa 1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1aa1a1a1111a111aaaaaaaaaa11aaaaaaaaaa +a11111a1aa a1aaaaaaaaaaaaaaaaaaaaaa1a11111aaaaaaaaaaaaaaaaaaaaaaaaaaa11aaaaaaaaaa +aaaaaaaaaa aaaaaaaaaaa
Output prints some '1's in between 'a'.
could anyone explain me what is happening with the code ?

"Keep pouring your ideas"

In reply to strange behaviour when forking lots of times by jesuashok

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?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (3)
    As of 2019-12-08 18:38 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?