执行perl时,'$'转换为'2918 1174 2918' [英] '$' gets converted to '2918 1174 2918' when executing perl
问题描述
我有一个吐出html页面的perl。我想使用jquery操作html页面。我已将所有jquery代码放入字符串并将该字符串放入
I have a perl that spits out an html page. I want to manipulate the html page using jquery. I have put all the jquery code into string and put that string inside
<script type='javascript'> code </script>
阻止。但是当我执行perl时,我的所有 $
符号都转换为 2918 1174 2918
。
所以如果我的代码是 $(。className)
现在我得到 2918 1174 2918(。className)
block. But when I execute perl, all of my $
symbols gets converted to 2918 1174 2918
.
So if my code was $(".className")
now I get 2918 1174 2918(".className")
有人可以指导我吗?我的代码如下:
Can anyone please guide me? My code is as below:
my $str = "<html><head><script type='text/javascript' src='js/top5jquery-1.6.2.min.js'>";
$str .="<script type='text/javascript'>$('.submitButton').click(function(){ alert('clicked submit button'); });";
$str .="</head><body><input type='submit' value='submit' />Submitting</body></html>";
my $file_name = "/mainDirectory/myfile";
my $fh;
open ($fh, "> $file_name") or die "Can not open $file_name to write";
print $fh $str;
close($fh);
推荐答案
$(
是Perl中的有效变量名。
$(
is a valid variable name in Perl.
它表示当前进程的真实组ID,并包含用户所属的所有组ID的空格分隔列表。
It means the "real group id" of the current process, and contains a space separated list of all the group ids that the user belongs to.
要在插入字符串的上下文中使用Perl中的文字 $(...
,您需要将其转义,例如:
To use a literal $(...
in Perl in a context where strings are interpolated, you need to escape it, e.g.:
\$(".classname")
这篇关于执行perl时,'$'转换为'2918 1174 2918'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!