[英]Issue with eval_in_page - Trying to interpolate an array
my @para_text = $mech->xpath('/html/body/form/table/tbody/tr[2]/td[3]/table/tbody/tr[2]/td/table/tbody/tr[3]/td/div/div/div', type => $mech->xpathResult('STRING_TYPE'));
#BELOW IS JUST TO MAKE SURE THE ABOVE CAPTURED THE CORRECT TEXT
print "Look here: @para_text";
$mech->click_button( id => "lnkHdrreplyall");
$mech->eval_in_page('document.getElementsByName("txtbdy")[0].value = "@para_text"');
In the last line of my code I need to put the contents of the @para_text array as the text to output into a text box on a website however from the "document" till the end of the line it needs to be surrounded by ' ' to work. 在我的代码的最后一行中,我需要将@para_text数组的内容作为文本输出到网站上的文本框中,但是从“文档”到该行的末尾都需要用''包围。上班。 Obviously this doesnt allow interpolation as that would require " " Any ideas on what to do? 显然,这不允许插值,因为这需要“”关于操作的任何想法?
To define a string that itself contains double quotes as well as interpolating variable values, you may use the alternative form of the double quote qq/ ... /
, where you can choose the delimiter yourself and prevent the double quote "
from being special 要定义本身包含双引号以及内插变量值的字符串,可以使用双引号qq/ ... /
的替代形式,在该形式中您可以自己选择定界符并防止双引号"
特殊
So you can write 所以你可以写
$mech->eval_in_page(qq/document.getElementsByName("txtbdy")[0].value = "@para_text"/)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.