2009/05/15

String::CRC::Cksum module for 64-bit Perl

When I used the following command to install String::CRC::Cksum on my 64-bit Ubuntu,
perl -MCPAN -e "install String::CRC::Cksum"
the following error message is shown and perl rejected to install it:
Use of uninitialized value in bitwise xor (^) at at /usr/local/share/perl/5.10.0/String/CRC/Cksum.pm line 73.
I managed to google the solution but in vain. Finally, I realized the problem is caused by 64-bit integer on my 64-bit Ubuntu.

To fix this problem, force to install String::CRC::Cksum module first:
$ sudo cpan
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.9205)
ReadLine support available (maybe install Bundle::CPAN or Bundle::CPANxxl?)

cpan[1]> force install String::CRC::Cksum
and then patch it (/usr/local/share/perl/5.10.0/String/CRC/Cksum.pm, "chmod" first! it's read-only):
--- Cksum.pm    2009-05-15 00:33:20.000000000 +0800
+++ Cksum.pm 2009-05-15 00:25:36.000000000 +0800
@@ -70,7 +70,7 @@

for(my $i = 0; $i < $n; ++$i) {
my $c = unpack 'C', substr $_[0], $i, 1;
- $cksum = ($cksum << 8) ^ $crctab[($cksum >> 24) ^ $c];
+ $cksum = ($cksum << 8) ^ $crctab[(($cksum >> 24)&255) ^ $c];
++$size;
}

@@ -111,7 +111,7 @@
while($size != 0) {
my $c = $size & 0377;
$size >>= 8;
- $cksum = ($cksum << 8) ^ $crctab[($cksum >> 24) ^ $c];
+ $cksum = ($cksum << 8) ^ $crctab[(($cksum >> 24)&255) ^ $c];
}
$cksum = ~ $cksum;

沒有留言: