use warnings; use strict; $_ = 'The The duplicate duplicate string string ..'; s/\b((\w)+ | (.)+) \1\b/$1/g; print "$_\n";