Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re2: remove duplicates

by blakem (Monsignor)
on Oct 11, 2002 at 08:14 UTC ( #204444=note: print w/replies, xml ) Need Help??


in reply to Re: remove duplicates
in thread remove duplicates

If you're going to split and use a hash to check for uniqueness, its still possible to retain the original order (first occurances only, of course)
my %seen; $text = join(' ', grep !$seen{$_}++, split(' ',$text));
Though, this removes all the newlines as well....

-Blake

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://204444]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2019-08-21 23:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?