in reply to Bad nstore of a shared hash
threads::shared::tie does not play nice with Storable. The solution is to make a copy of the hash before writing it to disk:
#! perl -slw use strict; use threads; use threads::shared; use Storable qw[ nstore retrieve ]; use Data::Dump qw[ pp ]; my %hash :shared = ( a=>1, b=>1, ); async { nstore { %hash }, 'fred.bin'; }->join; my $hash2 = retrieve 'fred.bin'; pp $hash2; __END__ C:\test>junk42 { a => 1, b => 1 }
That does mean you'll have to share_clone() it if you need it shared once you retrieve() it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Bad nstore of a shared hash
by daverave (Scribe) on Sep 21, 2010 at 23:24 UTC | |
by BrowserUk (Patriarch) on Sep 21, 2010 at 23:36 UTC | |
by daverave (Scribe) on Sep 22, 2010 at 17:38 UTC |