e.g.
Town\tCounty
Westminster\tGreater London
King's Cross\tGreater London
Mayfair (north)\tGreater London
Mayfair (south)\tGreater London
...
####
Town\tCounty\tVALUE
####
$tmp=(get the file contents);
$tmp=~s/\r//g;
$tmp="\n$tmp\n";
($n,$v)=[got from somewhere, same as list items]
($ctr)=[got from somewhere else]
($rctr)=[count of replacements made]
## attempt 1
if ($tmp=~/^$n\t$v$/) {
$tmp=~s/^$n\t$v$/$n\t$v\t$ctr/;
$rctr++;
} else {
....
####
# attempt 2
$n=~s/\(/\\(/g; ## << this works ok!
$n=~s/\)/\\)/g;
$n=~s/\'/\\'/g; ## << same method, NO WORK!
if ($tmp=~/^$n\t$v$/) {
$tmp=~s/^$n\t$v$/$n\t$v\t$ctr/;
$gctr++;
}