Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hiya.
OK, maybe im looking in the wrong places or something, I found loads on removing duplicates from arrays but the examples they gave only seemed to work for integers.
One solution is to pop off each element of the array and compare it against every other element remaining. If there's a match, chuck it, otherwise it must be unique so add it to @output. Surely there's a more efficient perlesque way though?
So the idea is if I have an array:
The output should be:@array = ("abc","def","abc","ghi","ghi","abc","jklm","abc","def")
Can someone offer a Perl newbie a hand?!@output = ("abc","def","ghi","jklm")
Also can anyone suggest other good sites I can draw code samples/tutorials/information from?
Thanks!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Remove duplicate strings from an array
by Corion (Patriarch) on Mar 13, 2007 at 14:45 UTC | |
Re: Remove duplicate strings from an array
by liverpole (Monsignor) on Mar 13, 2007 at 14:45 UTC | |
Re: Remove duplicate strings from an array
by davorg (Chancellor) on Mar 13, 2007 at 14:45 UTC | |
Re: Remove duplicate strings from an array
by ferreira (Chaplain) on Mar 13, 2007 at 14:48 UTC | |
Re: Remove duplicate strings from an array
by johngg (Canon) on Mar 13, 2007 at 15:14 UTC | |
Re: Remove duplicate strings from an array
by agianni (Hermit) on Mar 13, 2007 at 14:47 UTC | |
Re: Remove duplicate strings from an array
by CountZero (Bishop) on Mar 13, 2007 at 15:39 UTC | |
Re: Remove duplicate strings from an array
by Anonymous Monk on Mar 13, 2007 at 16:02 UTC |
Back to
Seekers of Perl Wisdom