Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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 (start.pl) and two folders (Folder1 and Folder2) inside the parent folder. The start.pl forks a process in which it calls scripts from folder1 and folder2 randomly. I want a Global Variable to be defined in start.pl which should be available in forked process (Please note the Forked File is inside folder not on same path as start.pl). 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
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2014-12-29 13:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (188 votes), past polls