Perl 标志 -pe, -pi, -p, -w, -d, -i, -t? [英] Perl flags -pe, -pi, -p, -w, -d, -i, -t?

查看:42
本文介绍了Perl 标志 -pe, -pi, -p, -w, -d, -i, -t?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过很多运行 Perl 代码或脚本的方法,带有不同的标志.但是,当我尝试通过 google 搜索每个标志的含义时,我主要将结果发送到通用 Perl 站点,并且在那里找不到关于标志或其用途的具体信息.

以下是我最常遇到的标志,我不知道它们是什么意思:

  • perl -pe
  • perl -pi
  • perl -p
  • perl -w
  • perl -d
  • perl -i
  • perl -t

如果您能告诉我每个词的含义以及它们的一些用例,或者至少告诉我找出它们含义的方法,我将不胜感激.

解决方案

是的,众所周知,Google 很难查找标点符号,不幸的是,Perl 确实 似乎主要由标点符号组成:-)

命令行开关在 perlrun 中有详细说明.(通过调用 perldoc perlrun 从命令行获得)

一一简要介绍选项:

<前>-p:在您的命令周围放置一个打印循环,以便它作用于每个标准输入行.主要用于 Perl 可以击败在力量和简单性方面摆脱 awk :-)-n:在您的命令周围放置一个非打印循环.-e:允许您提供程序作为参数而不是比在文件中.您不想创建脚本每个小的 Perl 单行文件.-i:就地修改您的输入文件(备份原来的).无需 {copy,删除原始,重命名} 过程.-w:激活一些警告.任何优秀的 Perl 编码器都会使用它.-d:在 Perl 调试器下运行.为了调试你的 Perl 代码,明显地.-t:将某些污染"(可疑)代码视为警告(正确污点模式将在此可疑代码上出错).习惯牛肉提高 Perl 安全性,尤其是在运行其他代码时用户,例如 setuid 脚本或网络内容.

I have seen lots of ways of running Perl code or scripts, with different flags. However, when I try to google for what each flag means, I mainly get results to generic Perl sites and no specific information regarding the flags or their use is found there.

Below are the flags that I encounter most often, and I don't have a clue what they mean:

  • perl -pe
  • perl -pi
  • perl -p
  • perl -w
  • perl -d
  • perl -i
  • perl -t

I will be very grateful if you tell me what each of those mean and some use cases for them, or at least tell me a way of finding out their meaning.

解决方案

Yes, Google is notoriously difficult for looking up punctuation and, unfortunately, Perl does seem to be mostly made up of punctuation :-)

The command line switches are all detailed in perlrun. (available from the command line by calling perldoc perlrun)

Going into the options briefly, one-by-one:

-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 :-)
-n: Places a non-printing loop around your command.
-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.

这篇关于Perl 标志 -pe, -pi, -p, -w, -d, -i, -t?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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