Paul Sobey wrote: > I'm using XML::Simple to read in two files, and generate two hashrefs. I > want to combine these two into a big hashref, like this: > > my $combined = { %{$a}, %{$b} }; > > This works fine, until I want to share the $combined hash to make it > visible across several threads. > > As an example, consider the following: > > use threads; > use threads::shared; > > > my $TestHash = { > bla => "bla", > wibble => [ "wibble", "wibble" ], > blargh => { > I => "Really", > Wish => "This", > Would => "Work" > } > }; > > my $TestHash2 : shared; > > $TestHash2 = $TestHash;
I tried reading the docs for shared and they are cryptic at best - try : my $TestHash2 = &share({}); $TestHash2 = $TestHash; in place of the above two lines. I don't understand the syntax at all. > This fails in my system with the error "Invalid value for shared scalar > at D:\scripts\thread2.pl line 17.". I can understand why this should > cause problems, since none of the nested references are themselves > marked as shared. How can I generate a shared version of the hashes that > I can pass around between the threads? I was considering some sort of > recursion through the structure, creating new :shared copies of each value? -- ,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED] (_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/ -/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff) _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs