perl获取匹配行的后几行

#!/usr/bin/perl

#用正则表达式匹配某一行,匹配上之后获取匹配行的后面几行
open (f,"D:\file");
while (<f>){
if (/TOTAL ELASTIC/){
$a=1;
$b=0;
}
if ($a){
print;
$b=$b+1;
$result=$result.$_;
}
if ($b==10){
$a=0;
}
}
print"----------------this is $result--------------------- ";
print $result;

原文地址:https://www.cnblogs.com/shunguo/p/11441676.html