$_ = 'abcdegedfc'; print "$1\n" while (/(?=((.+).?(??{quotemeta reverse $2})))/g);