我有一个从perl执行的SQL语句。
$my_sql = qq (
SELECT 1 AS ....
);那我就知道
my $sm = $dbh->prepare($my_sql);
$sm->execute;问题是我的SQL在许多地方都有这样的正则表达式。
value ~ '^[1-9][0-9]?/[1-9][0-9]?/[1-9][0-9]{3}$':因此,当我执行perl脚本时会出现错误,因为这些'$‘。
Use of uninitialized value $' in concatenation (.) or string at
DBD::Pg::st execute failed: execute called with an unbound placeholder at如何避免这些错误并使SQL语句正常工作?
发布于 2015-05-04 08:44:23
qq(something)只是"something"的另一种说法,而q(something)的意思是'something'。
"this"和'this'之间的区别是插值,它只在双引号内启用。
my $foo = 123;
print "<< $foo >>"; # prints << 123 >>
print '<< $foo >>'; # prints << $foo >>因此,由于$在''中不是特殊的符号,所以只需将qq更改为q即可。
https://stackoverflow.com/questions/30025475
复制相似问题