I have a text file, and I'm looking to omit some of the lines from the text file, and use that string to create a new file. The nice thing is that my text file starts the text chunk that I need with a line that includes "START" and ends with "END".
For example, my text file looks like:
1
2
3
Start
4
5
6
End
7
8
Start
9
10
End
The desired output would be two strings that I can output into text files that look like:
Start
4
5
6
End
Start
9
10
End
What I currently have so far:
open(RH, '<', $fileName) or die $!;
while(<RH>) {
#print $_;
chomp $_;
if ($_ eq 'START') {
$str = "$str"."$_\n";
}
}
But I'm not sure how to continue.
EDIT: I answered this question using:
$cmd = q(awk '/Start/,/End/ {print}' foo.txt);
my $output = qx($cmd);
my @cards = split (/(?<=\End)/, $output);