
perl
xdfwsl
真知困而得,峰高无坦途!
展开
-
perl判断文件是否存在 perl -e
主要就是 -e 这个操作符 ( e 即是 "exist" )$fileExist = -e "C:/windows/readme.txt";if ( $fileExist ) { print "Yes"}else { print "No"}print -e 'C:\windows\readme.txt';如果存在文件,就会输出1,否则没有输出。-e表示文件存在,判断是否...原创 2018-05-02 00:23:03 · 17950 阅读 · 0 评论 -
perl chomp
Perl functions A-Z | Perl functions by category | The 'perlfunc' manpage chomp VARIABLE chomp( LIST )chompThis safer version of chop removes any trailingstring that corresponds to the current ...原创 2018-05-05 11:10:53 · 315 阅读 · 0 评论 -
Perl if Statement
Summary: in this tutorial, you are going to learn about Perl if statement that allows you to control the execution of code conditionally.Simple Perl if statementPerl if statement allows you to control...原创 2018-05-05 11:01:47 · 255 阅读 · 0 评论 -
Perl printf Function
DescriptionThis function prints the value of LIST interpreted via the format specified by FORMAT to the current output filehandle, or to the one specified by FILEHANDLE.Effectively equivalent to print...原创 2018-05-05 09:42:46 · 166 阅读 · 0 评论 -
Perl printf 函数
printf函数可以格式化输出字符串用法:printf FILEHANDLE FORMAT, LIST printf FORMAT, LIST使用printf格式化输出printf 函数有一个模板,叫格式字符串,它可以规定输出的格式,每个格式符有百分号开头,由字母结束。格式化字符串中有3个格式符,则对应3个元素格式 作用%g 输出数字,它将根据需要自动选用浮点数,整数或者指数%d 十进制整数...转载 2018-05-05 09:36:11 · 504 阅读 · 0 评论 -
perl 程序 -e 选项
交互式编程你可以在命令行中使用 -e 选项来输入语句来执行代码,实例如下:交互式编程你可以在命令行中使用 -e 选项来输入语句来执行代码,实例如下:$ perl -e 'print "Hello World\n"'输入以上命令,回车后,输出结果为:Hello World...原创 2018-04-20 17:54:49 · 6630 阅读 · 0 评论 -
perl Getopt::Std模块的使用
处理命令行选项是一个很重复的事情,Getopt::Long 把这个过程简单化了。使用这个模块其实只要知道一些常用的用法就行了。这是文档中的例子:use Getopt::Long;my 观察一下 GetOptions 函数的参数,可以发现,大致可以把设置分为三个部分: (1)命令行的选项,对应于“length...转载 2018-04-20 17:40:23 · 693 阅读 · 0 评论 -
perl的unless控制结构
在perl的if控制结构中,只有当条件表达式为真时才执行某块代码。如果想让程序块在条件为假时才执行,此时可以把if改成unless例如:unless ($fred =~ /^([A-Z_]\w*$/i) { print "The value of \$fred doesn't look like a Perl identifier name. \n";}使用unless意味着,要么条件为真,...转载 2018-04-20 17:42:41 · 1034 阅读 · 0 评论 -
Perl的变量作用域:our、local、my、state
I.知识点概要: 1.变量范围分为两类:全局、局部 2.全局变量标准(our)关键字、局部变量标准(my)关键字 3.(local)关键字将全局变量临时借用为局部、(state)关键字将局部变量变得持久 在Perl中,所有的变量、子程序和其他可以被命名的实体默认都拥有包作用域(亦称“全局作用域”),也就是说它们存在于当前包的符号表中。 如果没有关键字声明变量,Perl会默认变...转载 2018-05-02 07:11:45 · 1221 阅读 · 0 评论 -
Perl chomp使用
如果字符串结尾有换行符,chomp 可以去掉它。这基本上就是它能完成的所有功能,如下例:$text = “a line of text/n”; #也可以由<STDIN>输入chomp($text); #去掉换行符(/n)。它非常有用,基本上你的每一个程序都会用到它。如你将知道,这是将字符串末尾换行符去掉的最好方法。基于Perl 中的一条基本原则:在需要使用变量的地方,可以使用赋值表达式...转载 2018-05-05 11:12:09 · 1010 阅读 · 0 评论