in reply to Re^2: Getting next line after matched one
in thread Getting next line after matched one
my $flag = 0; while (<FILE>) { #If not at end of file process next line if ($flag) { #flag is set, previous line was a match $flag = 0; #reset the flag do_something($_); #do what you want to do after finding match } if (/pattern/) { #if this line matches $flag = 1; #set the flag so I can do something on next line next; #go to next line, not required but might make more read +able } }
|
|---|