Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Filtering the repeated text in array

by ozgurp (Beadle)
on Apr 21, 2010 at 09:44 UTC ( #836004=perlquestion: print w/replies, xml ) Need Help??

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://836004]
Approved by BioLion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2022-05-25 13:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (90 votes). Check out past polls.

    Notices?