On 8/24/05, Brian Raven <[EMAIL PROTECTED]> wrote: > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Arijit > Das > Sent: 24 August 2005 16:42 > To: [email protected]; > [email protected] > Subject: Sharing Variables among Processes... > > > Its about sharing a Perl Variable among parent and child > processes. > > Do you know of any design pattern or technique by which this can > be achieved?
DirDB is designed for this purpose. The variable lives in the file system where it is available to any process that can read it. Presuming you're checking it pretty often it will stay in memory. Creating a DirDB::scalar that ties a scalar to a file would be trivial, for certain values of trivial --- slurp the file on FETCH, atomically overwrite the file on STORE (possiblky respecting some kind of lock discipline if you don't have a clobbering rename function), then you would have a $scalar that would have the same value in all processes and would update immediately. By using the technique of IPC-through-the-file-system. > You can share Perl variables between threads, however, if your Perl is > built with thread support. > > You don't say what you are trying to accomplish. Why do you think that > you need to share a Perl variable between 2 processes? if your Perl is not built with thread support there is the forks and forks::shared module suite that takes care of IPC to work just like threads. -- David L Nicol http://cronos.advenge.com/pc/Honest_Abe _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
