I am writing a script in perl where I use forking and I need to share variables among the separate processes. Currently I am using IPC::Shareable, which has been working great. However, it does not seem to work for a hash of hashes. For example:
$todo->{$next_todo_key}{'urls_hash'} = \%temp;
or
$todo->{$next_todo_key}{'url_idlist'} = $url_idlist;
Will give me the error IPC::Shareable::SharedMem: shmget: File exists.
at /usr/lib/perl5/site_perl/5.8.8/IPC/Shareable.pm line 566
Could not create shared memory segment: File exists
Does anyone know how to fix this? Or a similar module that will allow me to store a hash of hashes? Thanks!
I’d recommend giving DBM::Deep a try. You’ve probably gone beyond what a shared memory tool is going to give you if you need hashes of hashes.
You can store the DBM::Deep database in a RAM-disk if you really want it to be transient, or just use a temp file you can clean up at the end of your script run.