[oracle@june2 ~]$ cat a3.pl
my @allow_command=qw/ a1 a2 a3 a4/;
my $binary='a4';
if (grep m/$binary/,@allow_command ){print "11111111\n"};
[oracle@june2 ~]$ perl a3.pl
11111111
Perl 利用grep 判断元素是否在数组里
最新推荐文章于 2020-10-14 23:01:15 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)
[oracle@june2 ~]$ cat a3.pl
my @allow_command=qw/ a1 a2 a3 a4/;
my $binary='a4';
if (grep m/$binary/,@allow_command ){print "11111111\n"};
[oracle@june2 ~]$ perl a3.pl
11111111