Since none of the above code examples quite statisfied me, here's my solution..
# find duplicate entries in array @list my @sorted = sort (@list); my @duplicated; while (@sorted) { my $this = shift (@sorted); if ($this eq $sorted[0]) { push (@duplicated, $this); while (@sorted and $this eq $sorted[0]) { shift (@sorted); } } }
There is potential to shorten up this code and make it more obfuscated, but for learning purposes this should be alright..
Regards,
-octo
In reply to Re: See if arrays match
by flocto
in thread See if arrays match
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |