Hey all,
I am new to perl and am writing a text parser to wittle a large text file down and extract peices I need to an output file. I have code written that extracts the part I need but it is also extracting everything else in the file. It also seems to be running through the file a few times as information is repeated in my output file. Here is my code:
use strict;
use warnings;
open TEST, "tests.txt" or die $!;
open OUTPUT, "> output1.txt" or die$!;
my @file = grep/SUBSCRIBER/../NATIONAL/, <TEST>;
my $line;
foreach $line(@file) {
if ($line=~m/A1/) {
print OUTPUT @file; }
}
close TEST;
close OUTPUT;
I want the output file to just have the text located between SUBSCRIBER and NATIONAL if there is an A1 code on one of the lines.
Thanks!