in reply to Re: Storable: Byte order is not compatible
in thread Storable: Byte order is not compatible
I ran into the following problem: in our database, we have some frozen Perl hashes that were created with an old 32-bit version of Storable. While moving our application to a newer version of Linux and Perl and Storable, we discovered that the newer version of Storable, 64-bit, couldn't thaw the old frozen hashes.
I developed the following Perl solution, which works for the data that we have. The code can take something that an old, 32-bit Storable freeze created and convert it into something that a new, 64-bit Storable can thaw.
sub fix_frozen { my $frozen= shift; my $new= join( '', (qw/04 08 08 31 32 33 34 35 36 37 38 04 08 08 08/, (map {sprintf("%02x", ord($_))} (split //, substr($frozen, 11))))); $fixed_frozen=~ s/0{7}b/0{15}b/sg; join('', map {chr hex $_} ($fixed_frozen =~ /[0-9a-z]{2}/gi)); }
Keep in mind that this code will not work for all cases and that I've only ever tested it with the data that we have.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Storable: Byte order is not compatible
by Aristotle (Chancellor) on Apr 26, 2012 at 14:02 UTC | |
Re^3: Storable: Byte order is not compatible
by Anonymous Monk on Jun 19, 2012 at 21:58 UTC | |
by Anonymous Monk on Mar 21, 2015 at 19:33 UTC | |
by Anonymous Monk on Jun 19, 2012 at 22:38 UTC |