# https://theweeklychallenge.org/blog/perl-weekly-challenge-340/ use v5.12; use warnings; use Test::More; for my $case ('abbaca','azxxzy','aaaaaaaa','aabccba','abcddcba') { my $str = $case; say "*** Input: $str"; while ( $str =~s/(\w)\1// ) { say "Remove '$&' => '$str'"; } my $exp = $str; say "Expected Output : '$str'"; $str = $case; $str =~ s/((\w)(?1)?\g{-1})//g; say "Got Output : '$str'"; is($exp,$str,"'$case' ->'$str'"); say "...\n" } done_testing()