The simplest way is to redefine what is considered to be a line. That is done by setting $/ to the delimiter text.
You can look up the A and B values with a regex on the raw text in @errors, or else break that into a hash with A..D as keys.my @errors; { local $/ = "=================================\n"; open my $fh, '<', '/path/to/file.txt' or die $!; while (<$fh>) { chomp; push @errors, $_ if /D : Error Occurred/; } close $fh or die $!; }
After Compline,
Zaxo
In reply to Re: Get specified number of previous line text when encountered a text match in a file
by Zaxo
in thread Get specified number of previous line text when encountered a text match in a file
by tariqahsan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |