in reply to Problems with a search and replace script

Because the text is read from a file, all special characters are already escaped in the string... so "\t" is a literal "\t" rather than a tab. You could convert them to real tabs like this:
$buf2 =~ s/\\t/\t/g;

Hot Pastrami