Perl

作者: 无量儿 | 来源:发表于2021-12-03 16:03 被阅读0次

1、perl创建txt文件并写入内容
https://blog.csdn.net/qq_35697978/article/details/90515688

!/usr/bin/perl

open d,">1.txt";
print d "hello,world\nsee you\n";
close d;

2、判断文件是否存在,如果存在则删除
https://blog.csdn.net/jerry_1126/article/details/24588931

fileExist = -e "/home/etluser/zk/1.txt"; if (fileExist ) {
my @file="/home/etluser/zk/1.txt";
unlink @file;
}
else {
print "Don't exist.";
}

3、怎么用perl打开/处理.gz压缩文件
https://zhidao.baidu.com/question/264013198894843565.html

4、请问 在perl中 _ =~ s/\s*punc\s*/ /g; 是啥意思啊??
https://www.zhihu.com/question/21287054/answer/17765738

5、## Perl语言中的ig
假设比对原来的字符串不分大小写的话,就可加 i 修饰子:
str="Whatawonderfulwonderfulworld.";
str =~ s/w/www/ig; # str = "www a wwwonderful wwwonderful wwworld."

6、# [Perl]读取当前目录下的所有文件,包括子目录下的文件

7、Perl字符串比较和整数比较的区别详解
https://www.jb51.net/article/122833.htm

字符串比较操作符
操作符 描述 
lt 小于 
gt 大于 
eq 等于 
le 小于等于 
ge 大于等于 
ne 不等于

对比记忆:Shell if 条件判断(https://blog.csdn.net/zhan570556752/article/details/80399154
字符串判断
[ STRING1 = STRING2 ] 如果两个字符串相同则为真 ;
[ STRING1 != STRING2 ] 如果字符串不相同则为真 ;

8、perl -文件的打开,读写操作
https://blog.csdn.net/chenxieyy/article/details/53139866

向a.txt中写入内容

!/usr/bin/perl

open f,">a.txt";
print f "hello,world\nsee you\n";
close f;

如果a.txt原本有内容,则原内容将会被擦除,a.txt的内容为

9、=~ 念做 “does match" ,是匹配的意思

10、$ :类似^,匹配结尾

11、找出目录下面以*.zip结尾的文件
https://blog.csdn.net/champwang/article/details/46779323?utm_source=blogxgwz4

use File::Find;

my local_file = "D:\\temp\\log"; sub wanted { if ( -fFile::Find::name ) {
if ( File::Find::name =~ /\.zip/ ) {
print "File::Find::name\n"; # 路径加文件名 print "File::Find::dir\n"; # 路径
print "_\n"; # 文件名 print "\n\n"; } } } find(\&wanted,local_file);

相关文章

网友评论

      本文标题:Perl

      本文链接:https://www.haomeiwen.com/subject/dfsfsktx.html