sub alert { my $mesg = shift; print "alert('$mesg')\n"; } alert("Don't do that!"); #### sub quote { my $str = shift; # escape all slashes $str =~ s/\\/\\\\/g; # escape all single-quotes $str =~ s/'/\\'/g; return $str; }