[oracle@localhost ~]$ perl --help
Usage: perl [switches] [--] [programfile] [arguments]
-0[octal] specify record separator (\0, if no argument)
-a autosplit mode with -n or -p (splits $_ into @F)
-C[number/list] enables the listed Unicode features
-c check syntax only (runs BEGIN and CHECK blocks)
-d[:debugger] run program under debugger
-D[number/list] set debugging flags (argument is a bit mask or alphabets)
-e program one line of program (several -e's allowed, omit programfile)
#这个参数也常用,当在后面执行命令行时;如
[oracle@localhost ~]$ perl -e' print "ok\n"'
ok -f don't do $sitelib/sitecustomize.pl at startup
-F/pattern/ split() pattern for -a switch (//'s are optional)
-i[extension] edit <> files in place (makes backup if extension supplied)
#直接在原文件上做修改!做时记得做个备份
-Idirectory specify @INC/#include directory (several -I's allowed)
-l[octal] enable line ending processing, specifies line terminator
-[mM][-]module execute "use/no module..." before executing program
-n assume "while (<>) { ... }" loop around program
#当作是循环,此选项经常使用,假定一个文本有10行内容,那么如果要处理这10行,你就要加上此参数;
-p assume loop like -n but print line also, like sed
#暂时未看出是什么用处的
-P run program through C preprocessor before compilation
#在编译之前通过C预处理器运行
-s enable rudimentary parsing for switches after programfile
#待确定
-S look for programfile using PATH environment variable
#它会去$PATH目录中去寻找你要执行的程序,而不会在默认的当前目录
-t enable tainting warnings
#开启损坏警告
-T enable tainting checks
#开启损坏核对
-u dump core after parsing program
[oracle@localhost ~]$ cat perl01
#!/usr/bin/perl
print "what\n";
[oracle@localhost ~]$ perl -u perl01
Aborted -U allow unsafe operations
-v print version, subversion (includes VERY IMPORTANT perl info)
#直接输入perl -v 输出版本信息
-V[:variable] print configuration summary (or a single Config.pm variable)
#:直接输入perl -V 输出配置汇总
-w enable many useful warnings (RECOMMENDED)
[oracle@localhost ~]$ cat perl01
#!/usr/bin/perl
print what;[oracle@localhost ~]$ perl perl01
[oracle@localhost ~]$ perl -w perl01 #因为没有在print内容上加引号的告警,虽然直接执行没有报错!
Unquoted string "what" may clash with future reserved word at perl01 line 2.
Name "main::what" used only once: possible typo at perl01 line 2.
print() on unopened filehandle what at perl01 line 2.
-W enable all warnings #同上 (-w)
-x[directory] strip off text before #!perl line and perhaps cd to directory
#格式类似于:perl -xzbkdir perl01 #其中zbkdir为一目录名,具体用处还不详;
-X disable all warnings
[oracle@localhost ~]$ perl -X perl01
[oracle@localhost ~]$
[oracle@localhost ~]$ cat perl01
use warnings;
#!/usr/bin/perl
print what;
[oracle@localhost ~]$ perl perl01
Unquoted string "what" may clash with future reserved word at perl01 line 3.
Name "main::what" used only once: possible typo at perl01 line 3.
print() on unopened filehandle what at perl01 line 3.
[oracle@localhost ~]$ perl -X perl01 #忽略里边use warnings的告警提示;
兴例:
(1)-ne
[oracle@localhost ~]$ cat >01.txt
first
second
third
[oracle@localhost ~]$
[oracle@localhost ~]$ perl -e '
> print;
> ' 01.txt
[oracle@localhost ~]$
[oracle@localhost ~]$ perl -ne'
> print;
> ' 01.txt
first
second
third
[oracle@localhost ~]$
#可以看到只有加入了-n选项后才能将文中的内容循环的输出;(2)-i
#在原文件基础上直接修改
[oracle@localhost ~]$ perl -i -ne'
> s/first/last/ig;
> print;
> ' 01.txt
[oracle@localhost ~]$ cat 01.txt
last
second
third#以上操作要切记备份,以免悲剧发生!
perl基础知识02【代码执行格式】
原创mb646da62f0d7e4 ©著作权
©著作权归作者所有:来自51CTO博客作者mb646da62f0d7e4的原创作品,请联系作者获取转载授权,否则将追究法律责任
下一篇:非分区表与分区表相互转换
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Python基础知识-5
介绍python的各种应用实例
python -
Python基础知识-4
主要记录文本与正则,排列组合等相关内容
python 文本文件 日期 正则 随机数 -
perl基础知识01【perl用处】
1.什么是perl?2.它用来做什么?3.如何学会它?回
perl SQL 数据库 -
perl基础知识03【语法】
语法:先看一小段语
perl 当前目录 执行程序 -
SpringMVC框架基础知识(02)
【补】2. 为什么要使用SpringMVC框架在原生的Java EE技术体系中,处理用户请求的
java spring 请求参数 客户端 -
CA证书02-基础知识-证书基本格式
证书格式和编码,证书格式转换
数据 格式转换 签名算法 CA 证书格式 -
ABAP基础知识 ABAP执行JAVASCRIPT代码
点击蓝字 关注我们一前言ABAP语言作为一个相对封闭的语言,很难在网上找到一些经典算法的源代码.尝试自行通过
ABAP javascript 经典算法 -
perl基础知识05【数据流控制】
内容目录:1.能正常写出语句的结构语
oracle perl 循环结构