in reply to remove duplicates

Maybe you should be more explicit with your requirements. For instance, do you want to keep the order of the (first-) occurrences of each word?

If not, doing a split on whitespace, using each list element as a hash key and flattening the result with keys() will give you the list of unique words.

my $string = "foo bar ..."; my %L; map($L{$_}++, split(/\s/, $string)); # bonus: each hash element has the number of occurrences as value. $string = join(' ', keys(%L));
HTH!
note: this is untested...

--
Cheers, Joe

Replies are listed 'Best First'.
Re2: remove duplicates
by blakem (Monsignor) on Oct 11, 2002 at 08:14 UTC
    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