in reply to perl search and replace

$string =~ s/(.)\1/${1}2/gi;