![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
perl
文章平均质量分 80
wgz7747147820
这个作者很懒,什么都没留下…
展开
-
perl如何设置@INC
今天在一个新环境下运行perl程序,发现@INC没有包含当前目录,不确定是为啥,需要在@INC下加上当前目录做了如下修改,然后perl程序就可以运行成功了/etc/profileexport PERL5LIB=./https://perlmaven.com/how-to-change-inc-to-find-perl-modules-in-non-standard-locations#####################################When using modules t原创 2022-05-09 10:01:36 · 1161 阅读 · 0 评论 -
shell和perl的比较运算符
perl的比较运算符数值 字符串 意义== eq 相等!= ne 不等< lt 小于 gt 大于<= le 小于或等于= ge 大于或等于<=> cmp 返回值-1/0/1shell的比较运算符文件比较运算符-e filename 如果 filename 存在,则为原创 2020-10-30 21:20:01 · 204 阅读 · 0 评论 -
perl几种调用操作系统命令或者脚本的方式及优缺点
exec(@COMMANDS);优点: 在当前进程直接运行外部命令或者脚本,对外部命令或者脚本返回状态捕获较好!缺点: 如果出错直接退出perl脚本,无法捕获@COMMANDS的输出。system(@COMMANDS) or die (ERROR:$?);优点: fork子进程执行外部命令或者脚本,外部命令或者脚本出错,不会影响当前进程,对外部命令或者脚本的返回状态捕获较好。缺点:无法捕获@commands输出。@return=COMMANDS;优点: 能捕获脚本的STDOUT输出..原创 2020-10-30 10:38:57 · 777 阅读 · 0 评论 -
获取数组大小
my @arr = (2);print scalar @arr; # First way to print array sizeprint $#arr; # 得到数组最后一个元素的索引值my $arrSize = @arr;print $arrSize; # Third way to print array sizehttps://blog.csdn.net/lbt_dvshare/article/details/97788499转载 2020-10-12 22:43:26 · 496 阅读 · 0 评论 -
perl通过不调用sql文件的方式获取数据库数据的方法
[oracle@slcm05adm04 cdb1]$ cat 1.pl#!/usr/bin/perluse strict;use config_wgz;my $config_file='config.cfg';my $orahome = get_param_value($config_file,'orahome');my $tns_admin=get_param_value($config_file,'tns_admin');chomp $orahome;chomp $tns_admin;原创 2020-10-11 16:13:26 · 153 阅读 · 0 评论 -
unlink: cannot unlink ‘killsess.sql’: No such file or directory
[crsusr@slcz01db04 20200608]$ cat stop_cf2020607_141912_20200608_084741.logunlink: cannot unlink ‘killsess.sql’: No such file or directoryunlink: cannot unlink ‘killsess.sql’: No such file or directorycat能正确展示的字符,在vi的时候会显示为乱码unlink: cannot unlink �~@原创 2020-06-08 22:55:20 · 455 阅读 · 0 评论 -
perl的两个小于号用法
没想明白是为啥 [root@rwsoda203db1 perl_tidb]# cat p.pl#!/usr/bin/perluse strict "subs";use strict;use v5.16;print <<`EOC`;echo hi thereecho lo thereEOCprint <<EOCecho hi thereec...原创 2019-05-23 11:27:54 · 1447 阅读 · 0 评论 -
perl的上下文例子
[root@rwsoda203db1 perl_tidb]# cat p.pl#!/usr/bin/perluse strict "subs";use strict;use v5.16;my @files;$files[0]='a.txt';$files[1]='b.txt';$files[2]='c.txt';$files[3]='d.txt';print "@files...原创 2019-05-23 13:53:24 · 224 阅读 · 0 评论 -
perl的qx用法
[root@rwsoda203db1 perl_tidb]# cat p.pl#!/usr/bin/perluse strict "subs";use strict;use v5.16;my $perl_info = qx(ps $$);my $shell_info = qx 'ps $$';print "perl_info $perl_info\n";print "shell...原创 2019-05-23 14:49:57 · 1779 阅读 · 0 评论 -
perl中的特殊文件句柄
print "Readable \n" if -r _;下划线_ 是个特殊的文件句柄 special file handlehttps://stackoverflow.com/questions/46215052/what-is-single-underscore-in-perl-without-or参考一下原创 2019-05-23 16:35:20 · 320 阅读 · 0 评论 -
perl的几种产生异常方式
[root@rwsoda203db1 perl_tidb]# cat p.pl#!/usr/bin/perluse strict "subs";use strict;use v5.16;use warnings;use Carp;carp "Can not open file AAA.TXT $!\n" unless open(F,"<","AAA.TXT");print ...原创 2019-05-28 09:57:28 · 613 阅读 · 0 评论 -
perl的进程间通信(信号)
[root@rwsoda203db1 perl_tidb]# cat p.pl#!/usr/bin/perluse strict "subs";use strict;use v5.16;use warnings;use Carp;$SIG{INT} = sub { die "\nReceive INT signal. \nQuit this perl script.$!\n";};...原创 2019-05-28 10:26:27 · 278 阅读 · 0 评论 -
perl的”定义或“例子
[root@rwsoda203db1 perl_tidb]# cat p.pl#!/usr/bin/perluse strict "subs";use strict;use v5.16;#//定义或 如果$child_id已定义 则返回$child_id,如果$child_id undef,则执行diemy $child_id = fork() // die "cann't for...原创 2019-05-23 21:36:45 · 422 阅读 · 0 评论 -
perl和python的读写文件例子
[crsusr@linux2 python_tidb]$ cat mypy01.py#!/usr/local/bin/python3import glob,sysF = open('samp_python.txt','w')#sys.stdin = FF.write('first line\n')F.write('second line\n')F.write('third lin...原创 2019-05-30 22:40:11 · 234 阅读 · 0 评论 -
python的字典与perl的hash的对比
[crsusr@rws1270149 python_study]$ cat mypy.py#!/usr/bin/python3.7#字典实例 python的字典等同于perl的hashdict1 = dict(name='wang fang',age=42,salary=400000)#perl hash的下标用的是{},python的下标无论是列表还是字典都使用的是[]中括号pr...原创 2019-05-29 10:35:37 · 1148 阅读 · 0 评论 -
perl和python的数据类型对比
perl的数据类型有1.标量(标量是包括数字、字符串、日期等,但perl没有细分这些字符串),标量声明的时候用$标识my $var_a = '3';2.数组,perl的数组是用@标识的,一个变量前面有@标识这是个数组my @array_1 = ('wang','tian','zhong',3);3.hash hash标识是用% my %hash_1 = ('wang','WANG','...原创 2019-05-29 10:56:25 · 302 阅读 · 0 评论 -
perl open文件时碰到的一个问题
最近在写perl脚本时碰到一个问题open(CMD_FILE,">>$cmd_file");当时open一个文件时,最后的“号少写了,编译时没有报错,运行时也没有报错,但是文件没有创建成功,经过排查发现是少写了一个引号。...原创 2019-08-07 15:21:26 · 851 阅读 · 0 评论 -
perl中的标签和next last语句练习
[root@rwsoda203db1 perl_tidb]# cat p.pl#!/usr/bin/perlmy $var_i =0;OUT: while ($var_i <8) { $var_i++; INN: for (my $var_h = 1;$var_h<5; $var_h++){ if($var_i == 3){ next OUT; } if(...原创 2019-05-23 10:07:08 · 395 阅读 · 0 评论 -
perl里一些数组 hash的测试操作
[root@rwsoda203db1 perl_tidb]# cat p.pl#!/usr/bin/perl#数组赋值给数组my @array1=("a","b","c");#hash赋值给hashmy %hash1 = ("a"=>"A","b"=>"B");#数组赋值给标量$array1[3]=["d","e"];#hash赋值给标量$array1[4]=...原创 2019-05-22 16:53:50 · 400 阅读 · 0 评论 -
perl进程间通信第一个程序
虽然大部分代码看不懂,虽然格式很烂,但是等当看到通讯成功时,还是很高兴的server端程序[root@rwsoda203db1-vip perl_tidb]# cat perl_tidbvip.pl#!/usr/bin/perluse IO::Socket;use IO::Select;%srv_info=("clt_ip"=>"10.210.80.8","clt_por...转载 2019-05-20 15:47:03 · 179 阅读 · 0 评论 -
perl连接mysql
$dsn的详细用法my $dsn = "dbi:mysql:database=${db_name};hostname=${db_host};mysql_socket=${db_sock};port=${db_port};mysql_compression=1;mysql_read_default_file=$ENV{HOME}/.my.cnf;mysql_read_default_group=c...原创 2019-05-20 22:51:40 · 821 阅读 · 0 评论 -
perl--DBI使用详解(二)
https://blog.csdn.net/herokoking/article/details/60123334参考一下,非常好转载 2019-05-20 23:13:27 · 566 阅读 · 0 评论 -
我的第一个perl dbi脚本
使用perl dbi连接mysql并插入一条数据[root@rws1270149 script_wgz]# cat mysql.pl#!/usr/bin/perluse DBI;my $host="127.0.0.1";my $port="3306";my $user="root";my $password="password";my $db_name="db100";my $s...原创 2019-05-20 23:15:38 · 295 阅读 · 1 评论 -
perl IO::Socket 简介
http://www.360doc.com/content/12/0423/14/116188_205880702.shtml对perl socket的各种方法做了一个讲解,感觉还算比较清楚转载 2019-05-21 10:23:29 · 461 阅读 · 0 评论 -
Perl学习笔记(十)--通过DBI访问数据库
http://www.cnblogs.com/Hebe/p/4448187.html参考一下转载 2019-05-21 10:40:17 · 387 阅读 · 0 评论 -
如何查找一个perl module所在的文件
我们想去看看某个module的源代码,比如某个module的某个子例程,需要首先找到这个文件,就可以使用下面的方法[root@rwsoda203db1-vip perl_tidb]# perldoc -l IO::Select/usr/lib64/perl5/IO/Select.pm[root@rwsoda203db1-vip perl_tidb]# perldoc -l strict/u...原创 2019-05-21 16:51:11 · 528 阅读 · 0 评论 -
perl正则表达式匹配后的各种变量
[root@rwsoda203db1 perl_tidb]# cat p.pl#!/usr/bin/perluse strict "subs";use strict;use v5.16;my $n = 3;my $str = "first . <EM>PARENT</EM> LAST";$str =~ m# (<.*?>)(.*?)(</....原创 2019-05-25 17:25:55 · 2226 阅读 · 0 评论 -
perl的函数原型例子
[root@rwsoda203db1 perl_tidb]# cat p.pl#!/usr/bin/perluse strict "subs";use strict;use v5.16;use warnings;my @a = (1,2,3,4,5);sub push_item(+$){ my $local_a = shift @_; my $local_item = shi...原创 2019-05-26 09:52:38 · 143 阅读 · 0 评论 -
perl的引用
标量引用 \$ $$数组引用 \@ @$hash引用 \% %$子例程引用 \& &$\$ \@ \% \& 会返回相应对象类型的一个标量引用(应该是对象的地址)$$ @$ %$ &$会返回对象本身...原创 2019-05-26 10:22:00 · 428 阅读 · 0 评论 -
正则表达式
[]里面的内容匹配一个字符[a-zA-Z_0-9]会匹配26个英文字符的大小写以及0到9数字还有下划线. 小数点匹配任何一个字符\s匹配单个空白符,是[\t\n\r\f ]的简写形式正则表达式的量词量词是用花括号括起来的{0,5}表示可以出现0到5次.{0,5} 表示任意字符可以出现0到5次量词+其实表示的意思是{1,}?等价于{0,1}*等价于{0,}...原创 2019-05-22 14:46:55 · 424 阅读 · 0 评论 -
perl进程间通信
http://blog.chinaunix.net/uid-26728839-id-3390019.html参考一下转载 2019-05-20 14:05:46 · 218 阅读 · 0 评论