我看到了许多运行perl代码或脚本的方法,有不同的标志。然而,当我尝试google的每个标志的意思,我主要获得结果到通用的perl网站,没有关于标志或其使用的具体信息。
下面是我最常遇到的标志,我不知道它们的意思:
> perl -pe
> perl -pi
> perl -p
> perl -w
> perl -d
> perl -i
> perl -t
如果你告诉我这些是什么意思和一些用例,或者至少告诉我一种找出它们的意思的方法,我将非常感谢。
解决方法
是的,Google臭名昭着的难以查找标点符号,不幸的是,Perl似乎主要是由标点符号组成:-)
命令行开关都详细在perlrun.(可以从命令行调用perldoc perlrun)
逐一简要介绍一下选项:
-p: Places a printing loop around your command so that it acts on each line of standard input. Used mostly so Perl can beat the pants off awk in terms of power AND simplicity :-) -e: Allows you to provide the program as an argument rather than in a file. You don't want to have to create a script file for every little Perl one-liner. -i: Modifies your input file in-place (making a backup of the original). Handy to modify files without the {copy,delete-original,rename} process. -w: Activates some warnings. Any good Perl coder will use this. -d: Runs under the Perl debugger. For debugging your Perl code,obvIoUsly. -t: Treats certain "tainted" (dubIoUs) code as warnings (proper taint mode will error on this dubIoUs code). Used to beef up Perl security,especially when running code for other users,such as setuid scripts or web stuff.