The problem is the content of the variable $what. It contains
$replaceme, and for the regular expression engine, this means
you want to replace a string 'replaceme' that follows the end
of the string, because that's what $ means. Of course, there
is no such string.
You might want to use something like:
$sql =~ s/\Q$what/$with/;
Abigail