Finally I managed to reduce the exceptions into generic rules, although that was more a question of analysing the requirement. Although this code uses 5 pattern matches one after another (the program is a one-off but might be needed again) I do recognise that it could be reduced into a single regexp for performance purposes using some of the suggestions made above, but I have good output now and need to move onto the next step of the real work, which is to sort out which programmers get to fix which obsolete identifiers, these being what the progam has now successfully searched and found.
A hearty thank-you to all those who contributed!
sub SmartSearch {
my $srch = shift;
s/\w+\s*${srch}//g;
s/\#$srch//g;
s/$srch\s*\w+//g;
s/$srch\#//g;
return /$srch/;
}