Merritt Krakowitzer wrote at Tue, 23 Jul 2002 09:48:13 +0200: > I would like to know how to compare 2 arrays. > > I have 2 arrays and I would like to compare the contents of the data. It doesn't >matter in which > order the data is stored so long as its the same. So comparing the bellow should >read true, but if > they didn't match it would be false. > > my @foo = qw( > foo bar cat dog > ); > my @bar = qw( > dog cat foo bar > ); >
As you want to compare the arrays as sets, you can use a Set::-module to compare if (Set::Scalar->new(@foo)->is_equal(Set::Scalar->new(@bar))) { # @foo eq @bar } (Set::Array is another useful module doing that). Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]