rsriram has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Array::Compare
by marto (Cardinal) on Jul 05, 2006 at 10:26 UTC | |
|
Re: Array::Compare
by davorg (Chancellor) on Jul 05, 2006 at 10:29 UTC | |
|
Re: Array::Compare
by adrianh (Chancellor) on Jul 05, 2006 at 10:20 UTC | |
|
Re: Array::Compare
by GrandFather (Saint) on Jul 05, 2006 at 10:25 UTC | |
|
Re: Using Array::Compare
by kabeldag (Hermit) on Jul 05, 2006 at 12:53 UTC | |
by davorg (Chancellor) on Jul 05, 2006 at 12:59 UTC | |
by kabeldag (Hermit) on Jul 05, 2006 at 13:11 UTC |