想要从具有多个数字的变量中精确匹配数字,这些数字由类似于 egrep 的管道符号分隔。下面是我尝试过的代码。
#!/usr/bin/perl
my $searchnum = $ARGV[0];
my $num = "148|1|0|256";
print $num;
if ($searchnum =~ /$num/)
{
print "found";
}
else
{
print "not-found";
}
预期 o/p
perl number_match.pl 1
found
perl number_match.pl 1432
not-found