I am interesting to grab 10 lines before it match the regex "critical" or "error" . currently I am printing $_ which gives me only the line of the regex match.
I Worte in perl the following:
#!/usr/bin/perl -w
use strict;
open LOG, "/Users/erangross/Projects/perl/log" or die;
while (<LOG>){
if (/critical | error/){
open (myFile, '>>parser_log.txt');
print myFile $_;
}
}