in reply to Re^2: no exit! (return)
in thread no exit!

Please restructure your code as follows:

if ($insql =~ m/.*~\w+~.*/) { print "MATCHED IT\n";} errmsg(1); die; };

You don't show the code of errmsg, but most likely it really returns a false value and thus prevents the die from executing.