go ahead... be a heretic | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
You should be more careful with your assertions:
Your code will consider @a1 and @a2 as equal when they clearly aren't. Your solution can only work when all array elements are unique and the order of elements is irrelevant. The original poster possibly wants an unordered comparision, but the problem with multiple identical elements remains. If you modify your code to use the hash as a counter, then it works better:
In the end, I guess what the poster really wants is what's called the symmetric difference between two sets, which is what you (for example) get by building @only_a1 and @only_a2. In reply to Re: Re: How do I compare two arrays?
by Corion
|
|