私のテキストファイル:
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」と一致した場合は、年齢を確認して年齢も比較する必要があります。