It looks like you have metacharacters in $key (*, right?) that you want interpreted literally. You cannot escape the entire scalar with a single \, you are only escaping the dollar sign -/\$key/ will match the string '$key'.
If you quote $key with /\Q$key\E/, that should give you what you want.
For more info, try perldoc perlre.