in reply to unable to store shared hash with Storable

You could use JSON or YAML instead. I hear they're even faster since they doesn't try to be as precise as Storable, which is also the very reason why they'll solve your problem too.
  • Comment on Re: unable to store shared hash with Storable

Replies are listed 'Best First'.
Re^2: unable to store shared hash with Storable
by traceyfreitas (Sexton) on Aug 11, 2011 at 01:01 UTC

    JSON's encode() function would create a UTF8 text string out of the shared hash, so I just decoded() it back into an (unshared) HREF, and then I just stored that.

    my $encoded = JSON::XS->new->utf8->encode( $HREF ); my $decoded = JSON::XS->new->utf8->decode( $encoded ); store $decoded, $filename1;
    or I could just slap it all into one statement:
    store(JSON::XS->new->utf8->decode( JSON::XS->new->utf8->encode( $HREF ) ), $filename1);
    and all is well in the universe again!
      Well, I was suggesting you could use JSON *instead* of Storable — they're both tools to serialise data structures — but that works too :)
Re^2: unable to store shared hash with Storable
by traceyfreitas (Sexton) on Aug 10, 2011 at 23:46 UTC

    I've read YAML was the way to go, but the Dump() interface would just push out ASCII text. I did another check and it appears the YAML::XS might generate the binary for me. Thanks for the suggestions! I'll report back after trying it out.