in reply to Perl, JavaScript and quoting/escaping

From the perl side you can make use of other quoting mechanisms:
print q{<a href="onclick=some_javascript_function(self)"></a>};

Just define some_javascript_function() to do what you want.