in reply to perl search and replace

Yes it can, but your s/// fails on both accounts: it doesn't match duplicated letters, and it doesn't keep track of what character that was. Here is code that matches duplicated letters and replaces the second one with a '2':
$string =~ s/([a-zA-Z])\1/${1}2/g;
Note these things: If you don't care about case, you can use the /i modifier, like so:
$string =~ s/([a-z])\1/${1}2/ig;
Please read perlretut for more.

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart