my %seen; $string =~ s/(.)/$seen{$1}++ ? "" : $1/gse;