perl 运算符

前端之家收集整理的这篇文章主要介绍了perl 运算符前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
11111[root@jhoa bin]# cat 2.pl 
$var="cd";
if ($var eq "cd"){print "11111"};

[root@jhoa bin]# perl 2.pl 
11111[root@jhoa bin]# 


字符窜相等用 eq

数字相等用==

my $command="cd /tmp";
print "\$command  is $command:\n";
my $newdir=(split /\s+/,"$command")[1]; ---取第2个元素
print "\$newdir is $newdir:\n";


[root@jhoa bin]# perl a1.pl 
$command  is cd /tmp:
$newdir is /tmp:


或运算符
[oracle@jhoa ~]$ cat s3.pl 
$i = "bfsdf";
if ($i =~ /a|b/){print "11111\n";}


[oracle@jhoa ~]$ perl s3.pl 
11111

猜你在找的Perl相关文章