in reply to Checksum on Multidimentional Array - how does it work
Because you're not checksumming the arrays. You are checksumming the lengths of the arrays (which are the same):
my $ref_array1 = @array1; ## Assigns the length of @array1 to $ref_ar +ray!!! my $ref_array2 = @array2; ## Ditto!
To checksum the contents of the arrays, one way would be to serialise them (convert to a string representation):
#!C:\Perl5.16\bin\perl.exe use Data::Dumper; use Digest::MD5 qw(md5 md5_hex md5_base64); my @array1 = ( [1,'John','ABXC12132328'], [0,'John','ABXC12132322'], [0,'John','ABXC12132322'], [0,'John','ABXC12132322'], [0,'John','ABXC12132322'] ); my @array2 = ( [0,'John','ABXC12132322'], [0,'John','ABXC12132322'], [0,'John','ABXC12132322'], [0,'John','ABXC12132322'], [0,'John','ABXC12132322'] ); #print Dumper(\@array1); my $ref_array1 = Dumper( \@array1 ); my $ref_array2 = Dumper( \@array2 ); my $str = md5_hex($ref_array1); my $str2 = md5_hex($ref_array2); print "md-check-sum for array1 :: " . $str . "\n"; print "md-check-sum for array2 :: " . $str2 . "\n"; __END__ C:\test>1121378 md-check-sum for array1 :: b636a47153af27317478e3bca3632602 md-check-sum for array2 :: a4882627a89775602ab2e33762a70e81
Note also that I've nixed your unpack 'L', stuff which throws away 3/4 of the information in the 128-bit checksum by converting only the first 32-bits to a number.
|
|---|