in reply to re bug?

The $ character is a special regex character. You need to backslash it if you mean to match it specifically:
$re = '\$'; # or, better yet: $re = qr/\$/;


japhy -- Perl and Regex Hacker