Subject: | Perl thaw/freeze cross-arch issue |
Date: | Thu, 15 Feb 2007 17:59:02 -0800 (PST) |
To: | bug-Storable [...] rt.cpan.org |
From: | Amy N Dashiell <amydash [...] u.washington.edu> |
Hello,
I am running a 64-bit machine and ran into an issue with some code that uses thaw and freeze.
I used two machines (32 bit and 64 bit) so here is the info for those:
32 bit: perl version v5.8.7 built for i686-linux
OS stuff: uname -a
Linux noddy.ee.washington.edu 2.6.9-42.0.3.EL #1 Mon Sep 25 17:14:19 EDT 2006 i6 86 i686 i386 GNU/Linux
64 bit: perl version v5.8.7 built for x86_64-linux
OS stuff: uname -a
Linux lark.ee.washington.edu 2.6.9-42.0.3.ELsmp #1 SMP Mon Sep 25 17:24:31 EDT 2006 x86_64 x86_64 x86_64 GNU/Linux
I wrote two scripts, one called mrfreeze and one called mrthaw. I did the following tests:
freeze thaw result
32-bit 32-bit good
64-bit 64-bit good
32-bit 64-bit Byte order error
64-bit 32-bit Byte order error
The full text of the byte order error is: Byte order is not compatible at blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/thaw.al) line 366, at ./mrthaw line 23
Here is the contents of my scripts:
##### mrfreeze #######
#!/usr/nikola/bin/perl
use strict;
use Carp;
use Storable qw(freeze thaw);
#use Compress::Zlib;
#local $Storable::interwork_56_64bit = 1;
my $sadstring = "hello";
my($fNm,$x)=('coldString', \$sadstring); # output file name, ref to dat to be compressed
my $sad2 = freeze $x;
open(FILE,">$fNm") || confess "\nWrite open failed for '$fNm': $!\n\n";
print(FILE $sad2) || confess "write fail on '$fNm: $!\n\n";
close(FILE) || confess "\nWrite close failed for '$fNm': $!\n\n";
print "String $sadstring just frozen. \n";
######### mrthaw ##############
#!/usr/nikola/bin/perl
use strict;
use Carp;
use Storable qw(freeze thaw);
#use Compress::Zlib;
#local $Storable::interwork_56_64bit = 1;
my($fNm)="coldString"; # name of file to read
open(FILE,$fNm) || confess "\nRead open failed for '$fNm': $!\n\n";
my $sad2;
while (<FILE>) {
$sad2 .= $_; # reader stops on 'newlines' seen in binary file
}
close(FILE) || confess "\nRead close failed for'$fNm': $!\n\n";
my $sadstring = thaw $sad2;
############# end of scripts ############
thanks very much for your help! Please let me know if you have any questions about this. I only just started using perl recently so I am very sorry if I left anything out or if there was something that wasn't clear.
Thanks!
Amy