开发者

Share variables between Child processes in perl without IPC::Shareable

I need to share variables between different Children processes and my Parent process in Perl without the use of IPC::Shareable.

I basically just need to have a global variable that all processes would be able to read/write to. Also, the variable only needs write access from the parent if that would make my answer simpler. The Children only need t开发者_如何学JAVAo read it.

Edit: My problem could also be solved if there is a way for me to pass a message from one child process to another


From the information you have provided it's difficult to tell which is the best solution, but there are a few options available to you:

  • pass a message between your processes using sockets, or pipes
  • use a database that both processes read and write to
  • use a file(s) that both processes read and write to (you could use signals to tell a process when it is time to read from a file)
  • set up a memcache server to share information

...However, since your real problem might actually be "how can I do something in Perl that requires a module that isn't installed on my system, and I don't have root control over this box and sysadmins can't or won't cooperate?". the best answer is "use local::lib", but you can read more options in Matt Trout's blog post "But I can't use CPAN!". (I swear I post this link every single week.)


Have you tried threads::shared?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜