perl 查询使用 -pie [英] perl query using -pie

查看:77
本文介绍了perl 查询使用 -pie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这有效:

perl -pi -e 's/abc/cba/g' hellofile

但这不会:

perl -pie 's/cba/abc/g' hellofile

换句话说 -pi -e 有效但 -pie 无效.为什么?

In other words -pi -e works but -pie does not. Why?

推荐答案

-i 标志接受一个可选参数(如果存在,必须紧跟在它之后,而不是在单独的命令中 -行参数),指定要附加到输入文件的名称以创建备份的后缀.编写 perl -pie 's/cba/abc/g' hellofile 会导致 e 被当作这个后缀,而 e 不是'不会被解释为普通的 -e 选项,Perl 会尝试运行位于 s/cba/abc/g 中的脚本,该脚本可能不存在.

The -i flag takes an optional argument (which, if present, must be immediately after it, not in a separate command-line argument) that specifies the suffix to append to the name of the input file for the purposes of creating a backup. Writing perl -pie 's/cba/abc/g' hellofile causes the e to be taken as this suffix, and as the e isn't interpreted as the normal -e option, Perl tries to run the script located in s/cba/abc/g, which probably doesn't exist.

这篇关于perl 查询使用 -pie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆