在 perl 中的子进程之间共享变量,无需 IPC::Shareable
我需要在 Perl 中的不同子进程和父进程之间共享变量,而不使用 IPC: :可共享。
我基本上只需要一个所有进程都能够读/写的全局变量。另外,如果这会使我的答案更简单,则该变量只需要来自父级的写访问权限。孩子们只需要阅读它。
编辑:如果有一种方法可以让我将消息从一个子进程传递到另一个子进程,我的问题也可以解决
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 to 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您提供的信息,很难判断哪个是最佳解决方案,但是您可以使用一些选项:
......但是,由于您的真实 问题实际上可能是“我怎样才能在 Perl 中做一些需要我的系统上未安装的模块的事情,并且我对此框没有根控制权并且系统管理员不能或不会合作?” 。最好的答案是“使用 local::lib”,但您可以阅读更多内容Matt Trout 的博客文章中的选项 "但是我无法使用 CPAN!”。 (我发誓我每周都会发布此链接。)
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:
...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.)
您是否尝试过threads::shared?
Have you tried threads::shared?