Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re2: remove duplicates

by blakem (Monsignor)
on Oct 11, 2002 at 08:14 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://204444]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-03-28 18:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found