Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Global Variables Across Files

by anshumangoyal (Scribe)
on Jul 17, 2012 at 03:55 UTC ( #982122=perlquestion: print w/ replies, xml ) Need Help??
anshumangoyal has asked for the wisdom of the Perl Monks concerning the following question:

I have a perl solution where in a folder there is a script ( and two folders (Folder1 and Folder2) inside the parent folder. The forks a process in which it calls scripts from folder1 and folder2 randomly. I want a Global Variable to be defined in which should be available in forked process (Please note the Forked File is inside folder not on same path as Also if the forked process updates that global variable that should be available (updated) for next forks that will happen. I have tried everything but nothing works except writing the value of variable in a file and then reading it. Is there any way out?

Comment on Global Variables Across Files
Replies are listed 'Best First'.
Re: Global Variables Across Files
by jwkrahn (Monsignor) on Jul 17, 2012 at 04:49 UTC
Re: Global Variables Across Files
by Neighbour (Friar) on Jul 17, 2012 at 06:49 UTC
Re: Global Variables Across Files
by zentara (Archbishop) on Jul 17, 2012 at 12:01 UTC
    Shared Memory segments sounds like a good solution for this. See forking with Storable and IPC::ShareLite for a decent example. Or google for more: "perl shared memory segments". The basic idea is you can share a few memory locations, by having a key, which you can pass to your forks.

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://982122]
Approved by kcott
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (12)
As of 2015-12-01 10:25 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (798 votes), past polls