Dear Monks, Is it possible to compare the contents of array using check sum algorithm ? objective - Lets say i have a 2 multidimensional array that may have few hundred thousand rows(lets sat 500,000 ) and my objective is to compare this 2 arrays using check-sum to find if they are different. i.e. lets say array-1 may have row-x which may be missing in array-2. Conceptually i want to find out why my check-sum function returns same result for 2 different arrays. Please advise how to go about it. I have tried a sample code with very small set of array , please advise why the check-sum shows same result for both array ?
#!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 = @array1; my $ref_array2 = @array2; my $str = md5($ref_array1); my $str2 = md5($ref_array2); print "md-check-sum for array1 :: ".unpack('L', $str)."\n"; print "md-check-sum for array2 :: ".unpack('L', $str2)."\n";
output shows as below
md-check-sum for array1 :: 2134629092 md-check-sum for array2 :: 2134629092
In reply to Checksum on Multidimentional Array - how does it work by udvk009
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |