我需要将一个字符串与一个字符串数组进行匹配。我正在搜索的字符串应该能够包含通配符。
#!/usr/bin/perl
#
## disable buffered I/O which would lead
## to deadloops for the Apache server
$| = 1;
#
## read URLs one per line from stdin
while (<>) {
my $line = $_;
my @array1 = ("abc","def","ghi");
$found = 0;
if (/$line/i ~~ @array1)
{
print "found\n";
}
else
{
print "not found\n";
}
}
我用输入测试这个脚本,abc
它返回not found
perl ./mapscript.pl
abc
not found