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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.