Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
My Prime focus is not forking but process some thing in a child process and get the values updated in parent.

So you want your son to learn French and your daugther to learn German, and you expect that you automatically speak both French and German as soon as both have finished learning. Does that work in real life? Nope. And it also won't work with fork()ed processes.

Please read fork-exec, fork, and perhaps also exec.

Generally, processes can't update other processes data. You need some kind of inter-process communication, or shared memory. Shared memory won't work well with Perl, because perl tends to move data around when its size changes. See perlipc for details on both ways.

Another option, with its own set of traps, is using threads. Threads give you lightweight "processes" inside a single process, and threads can actually share variables. See perlthrtut for details. Of course, this works only if all external programs you are using now are merged into a single big program (possibly by moving each program into a single module).


Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re^3: Global Variables Not Updated in Child Process by afoken
in thread Global Variables Not Updated in Child Process by anshumangoyal

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?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (6)
    As of 2018-05-27 08:39 GMT
    Find Nodes?
      Voting Booth?