Keep It Simple, Stupid | |
PerlMonks |
Re: Fast Way to Return Unique Array of Arrayby pg (Canon) |
on Sep 05, 2005 at 03:30 UTC ( [id://489130]=note: print w/replies, xml ) | Need Help?? |
This is not what the function is supposed to do. Take a look at the source code. It only understands the first level of your AoA. Copy and paste, modify a little bit:
Run it , you get print out similar to this:
Now it is obvious, all those four elements of the LIST are different and uniqe, and that's why the entire original AOA is returned. Update: Just to extend a little bit. uniq will work with this code, base on the way the AoA is formed. The input AoA is logically equal to your AoA. And the output is now the same as what you wanted. (I am not saying that this is a solution for you, as you probably cannot form your data like this or cannot do it easily. This only demos the nature of uniq(). )
Why does it work? Because the uniq function sees two uniq array refs.
In Section
Seekers of Perl Wisdom
|
|