in reply to How to remove duplicate characters in a string in place
Still executes in a loop, but gets all instances of each letter each time (thus avoids the even/odd issue you have).
use 5.010; my $str = "abcdefghiaabccdjklm"; my $substr; $substr = "" while $str =~ s/(.)(?:(.*?)\1(?{ $substr .= $^N }))+/$sub +str/; say $str;
Good Day,
Dean
In Section
Seekers of Perl Wisdom