As of Perl 5.10, you can simply do:
That's the smart match operator. Details on what it's testing in
perlsyn(1).
---
edit: On second thought, given that you said "order of the elements doesn't matter", you may need to sort first and/or try a different approach. (You'll see what I mean when you read perlsyn(1).)