Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Make中编写perl一行程序?_Perl_Makefile - Fatal编程技术网

如何在Make中编写perl一行程序?

如何在Make中编写perl一行程序?,perl,makefile,Perl,Makefile,我正在编写以下命令以提取makefile中的文本:- @awk '/Exported Layer/,/Total Polygons/' out_compare.err | perl -lane '$el=$F[3] if(/Exported Layer/); print "$el: $f[3]" if (/Total Polygons/);' | cat 但它给出了以下错误:- 无法修改标量赋值中靠近“]if”的-e行1处的常量项 由于编译错误,-e的执行已中止 你们有什么建议吗?:-) Ma

我正在编写以下命令以提取makefile中的文本:-

@awk '/Exported Layer/,/Total Polygons/' out_compare.err | perl -lane '$el=$F[3] if(/Exported Layer/); print "$el: $f[3]" if (/Total Polygons/);' | cat
但它给出了以下错误:-

无法修改标量赋值中靠近“]if”的-e行1处的常量项 由于编译错误,-e的执行已中止


你们有什么建议吗?:-)

Make对命令中的shell引用不敏感,因此Perl代码段中的
$
字符被解释为Make变量
$e
$F
。这些变量不存在于您的makefile中,并且被扩展为空,从而导致您看到的Perl语法错误

您需要从make中转义
$
字符,如下所示:

... perl -lane '$$el=$$F[3] if(/Exported Layer/); ...

另请参见。

对我有效。。。为什么要把它传给猫?您可以添加perl的_compare.err(导出的图层和总多边形之间的内容)版本吗?从您执行的位置:命令行或makefile?将
perl
替换为
echo
,并查看它是如何损坏的?PS-
$f[3]
应该是
$f[3]