I think part of your issue is your understanding of what \b
means. From perlre
A word boundary (\b ) is a spot between two characters that has a \w on one side of it and a \W on the other side of it (in either order), counting the imaginary characters off the beginning and end of the string as matching a \W .
This means \$AVG will never match /\b\$AVG/ because there is no word boundary between a backslash (\W) and a dollar sign (\W).
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.