johnnywang has asked for the wisdom of the Perl Monks concerning the following question:
Hi, the threads, threads::share modules allow sharing of some simple data structures among threads (e.g, scalar, array or hash), I'm in a situation where I need to share
a more complex structure, something like a hash or hash
references, several levels deep. The problem is that I obtained this structure from another module (e.g., XML::Simple), so I cannot really declare all the data inside to be "shared". Of course, updating such a structure can also be a pain if I want to keep the "shared" part straight. I've come up with a solution which is to serialize the structure into a scalar (such as using Storable's freeze/thaw), which works, but I feel bad about it. Any other solutions, comments? Thanks.
Comment on sharing complex data structure between threads
IIRC, there was some discussion of adding an rshare function to do this, either in threads::shared or on CPAN, but I'm not seeing it. Without that, serialization is probably your best bet.