Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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?

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2018-01-23 00:10 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (238 votes). Check out past polls.