perl菜鸟求助
我要对一个很大的flat file进行字符串替换(大概2G左右)
我运行了如下code
[root@linux]$ perl -pi.back -e "s/\"\|\"/^/g" filename
然后返回一个错误
Substitution loop at -e line 1, <> line 1.
如果是对一个比较小的文件操作不会报错
而且我之前运行类似的命令都不会有错
比如 perl -pi.back -e "s/^M/\n/g" filename
无论大小文件这样都很好
请问是什么原因
我运行了如下code
[root@linux]$ perl -pi.back -e "s/\"\|\"/^/g" filename
然后返回一个错误
Substitution loop at -e line 1, <> line 1.
如果是对一个比较小的文件操作不会报错
而且我之前运行类似的命令都不会有错
比如 perl -pi.back -e "s/^M/\n/g" filename
无论大小文件这样都很好
请问是什么原因
作者: paniff 发布时间: 2011-05-16
引号加引号还有反斜杠我已经无法理解你这个替换了
作者: zhlong8 发布时间: 2011-05-16
如果你实在不知道自己哪里错了查下 perldiag
QUOTE:
Substitution loop
(P) The substitution was looping infinitely. (Obviously, a substitution shouldn't iterate more times than there are characters of input, which is what happened.) See the discussion of substitution in Regexp Quote-Like Operators in perlop.
(P) The substitution was looping infinitely. (Obviously, a substitution shouldn't iterate more times than there are characters of input, which is what happened.) See the discussion of substitution in Regexp Quote-Like Operators in perlop.
作者: zhlong8 发布时间: 2011-05-16