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 reply to Re: How to remove duplicate characters in a string in place
by duelafn
in thread How to remove duplicate characters in a string in place
by punitpawar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |