Best practice for variables shared between processes?

Mark Fowler mark at
Mon Sep 20 22:15:58 BST 2010

On 20 Sep 2010, at 17:30, Roger Burton West <roger at> wrote:

> I wish to have two processes, a "producer" (which will create files) and
> a "consumer" (which will do something with them), running
> simultaneously. Ideally the producer would push filenames to a list as
> it finishes producing them, while the consumer would shift them off the
> same list (or loop-wait, if the list is empty).

I had a better thought after my last post. Have one process create
files and, when it's done with each file, atomically move them into a
known directory for the second process to, um, process and delete then
when done.

Your second process could simply scan the directory every few seconds,
or you could do something clever with your kernel's inotify. CPAN
search seems to suggest that File::ChangeNotify::Watcher and it's
subclasses would just be one abstraction that could do both of these,
but I've not tried these modules (if you do use them, I'd be
interested to hear how you got on)


More information about the mailing list