Hi, I have two arrays and I want to compare the contents to these two arrays. I installed Array::Compare and my code is as follows:

use Array::Compare;
my @arr1 = (1,2,3,4,5,6);
my @arr2 = (1,2,3,4,5,6);
my $comp = Array::Compare->new;
if ($comp->full_compare(\@arr1, \@arr2)) {
   print "Arrays are the same\n";
} else {
   print "Arrays are different\n";
}

I am using full_compare so that each and every element of the first array will be matched with the corresponding element of the second array. But, even through the two arrays have the same content, I encounter the message "Arrays are different". Can anyone tell me what would have went wrong in this? If I make a 'compare' or 'compare_len' the script is working perfectly.

Edit: Expanded title - davorg


In reply to Using Array::Compare by rsriram

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.