I have an SQL statement executed from perl.
$my_sql = qq (
SELECT 1 AS ....
);
Then I do
my $sm = $dbh->prepare($my_sql);
$sm->execute;
The issue is that my SQL has regex like this in many places.
value ~ '^[1-9][0-9]?/[1-9][0-9]?/[1-9][0-9]{3}$':
So I get errors when I execute the perl script because of these '$'.
Use of uninitialized value $' in concatenation (.) or string at
DBD::Pg::st execute failed: execute called with an unbound placeholder at
How can I avoid these errors and make the SQL statement work?
qq(something)
is just another way to say "something"
while q(something)
means 'something'
.
The difference between "this"
and 'this'
is interpolation, which is enabled only inside double quotes.
my $foo = 123;
print "<< $foo >>"; # prints << 123 >>
print '<< $foo >>'; # prints << $foo >>
So, since $
is not special symbol inside ''
, just change qq
to q
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.