我的文本文件:
Name: mak
Place: ynr
Age: 22
-------------
Name: john
Place: kkr
Age: 21
-------------
Name: mak
Place: knl
Age: 23
-------------
我正在做的是:
open(FILE, "path to file") or die "";
$check="mak";
@arr=<FILE>
for(@arr)
{
if ($_=/Name:\s(.*)/)
{
$a=$1;
if($a eq $check)
{
print "matched name"
}
#now i want if "mak" is matched then after that it should match the age and store it one variable and then compare it with other matched age with same name
}
}
我想先得到名字,如果它匹配为“mak”,那么我还需要检查年龄并比较年龄。