in reply to See if arrays match
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: See if arrays match
by redsquirrel (Hermit) on Jul 24, 2002 at 01:28 UTC | |
by flocto (Pilgrim) on Jul 24, 2002 at 09:46 UTC |