Perlスクリプト内でテキストレポートを開き、特定の行を見つけて配列に格納する必要があります。
this is my report which I need to process through:
matched pattern 1
line1:10
line2:20
line3:30
next matched pattern 2
line1:5
line2:10
line3:15
next matched pattern 3
lineA:A
lineB:B
lineC:C
.
.
------------------------------------
この部分は私のスクリプトです:
@numbers;
@numbers2;
@letters;
while (<FILE>)
{
if ($_ =~/matched pattern 1/ && $_ ne "\n")
{
chomp();
push (@numbers,$_)
}
if ($_ =~/next matched pattern 2/ && $_ ne "\n")
{
chomp();
push (@numbers2,$_)
}
if ($_ =~/next matched pattern 3/ && $_ ne "\n")
{
chomp();
push (@letters,$_)
}
}
次に、配列内で数字と文字を使用できます。これは私のレポートファイルの一部です
Maximum points per Lab
Lab1:10
Lab2:30
Lab3:20
Maximum points per Exam
Exam1:50
Exam2:50
Maximum points on Final
Final:150