名为 restrictedNames
的变量持有限制用户名列表。 SplitNames
是一个保留完整用户名集的数组变量。 现在我必须检查是否在 restrictedNames
变量中找到当前名称, 如使用 instr
。
@SplitNames = ("naag algates","arvind singh","abhay avasti","luv singh","new algates") and now i want to block all the surnames which has "singh" ,"algates" etc.
@SplitNames = ("naag algates","arvind singh","abhay avasti","luv singh","new algates")
$RestrictedNames="tiwary singh algates n2 n3 n4 n5 n6";
for(my $i=0;$i<@SplitNames;$i++)
{
if($RestrictedNames =~ m/^$SplitNames[$i]/ ) //google d this condition, still fails
{
print "$SplitNames[$i] is a restricted person";
}
}