http://www.perlmonks.org?node_id=836004

ozgurp has asked for the wisdom of the Perl Monks concerning the following question:

Dear All, I have an array with repeated text values like:
@Array = ("LL-F-NO-999-197", "LL-F-NO-999-191", "LL-F-NO-999-198", "LL-F-NO-999-191", "LL-F-NO-999-197", "LL-F-NO-999-198")
and I want to filter repeated text values, and after filtering:
@Array = ("LL-F-NO-999-191", "LL-F-NO-999-197", "LL-F-NO-999-198")
I was wondering if you could suggest an elegant way of filtering the repeated text. Thanks.

Replies are listed 'Best First'.
Re: Filtering the repeated text in array
by Ratazong (Monsignor) on Apr 21, 2010 at 09:53 UTC

    This is a frequently asked question - which makes it easy for us to answer: Just look here in the perlfaq (chapter 4).

    note: in case you want to find a solution on your own, use the following hint (also taken from the FAQ):

    Use a hash. When you think the words "unique" or "duplicated", think "hash keys".

    HTH, Rata

Re: Filtering the repeated text in array
by Anonymous Monk on Apr 21, 2010 at 09:48 UTC
      It's also in perlfaq4 (U: perldoc -q duplicate ), complete with examples.