in reply to
The Perl 5.10 "smart match" is a complex critter and what it does for complex data structures is hard to understand. But for simple array's, it works.
my @x = (1, 2, 3);
my @y = (2, 3, 1);
my @z = (1, 2, 4);
print "x and y are equivalent" if sort (@x) ~~ sort (@y);
# the sort order (numeric or alpha) doesn't matter
# as long as it is consistent.
x and y are equivalent
Oh, don't use either a or b for user Perl variables. In this case, it is ok, but $a and $b are special variables reserved for sort() and other uses. Unlike many other languages, $a is distinct from @a... the same name can be used for different variable types. However, "a" and "b" are so special that I cannot recommend that.
I see that I got a "down vote", well ok. Tell us what is wrong about this? I tend to stay away from this "smart match" thing, but it does work and is easy to understand for simple data structures - what it does for more complex structure IS hard to understand. The Perl sort algorithm works just fine for relatively small numbers of items.