reverse =~ /\A((.)\2+)/ and substr($_, -(length($1) / 2)) = '' for @strs; print map "$_\n", @strs; __output__ foox baryy bazaaa