my %seen; $text = join(' ', grep !$seen{$_}++, split(' ',$text));