如何在 perl 的 -e 的参数中使用文字单引号? [英] How can I use literal single quotes inside the argument to perl's -e?
本文介绍了如何在 perl 的 -e 的参数中使用文字单引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试创建一个简短的 perl
命令,该命令基于文本文件为我的数据库创建 SQL 插入.但是,我无法进入 SQL 使用的单引号
I try to create a short perl
command that creates SQL inserts for my DB based on a text file. However, I am not able to get in the single-quotes used by SQL
perl -pe '$i += 1; chomp; @a = split /\t/; $_ = "INSERT INTO XYZ VALUES($i, \'$a[4]\');\n"'
在意外标记`)'附近导致语法错误
results in a syntax error near unexpected token `)'
有什么想法吗?
推荐答案
perl -pe '$i += 1; chomp; @a = split /\t/; $_ = "INSERT INTO XYZ VALUES($i, \047$a[4]\047);\n";'
这篇关于如何在 perl 的 -e 的参数中使用文字单引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文