I have a rather large text file (about 1MB) that has 1000s of entries about 20 lines long a piece, plus alot of other junk in it. Each entry in the file I want begin with the word "DESCRIPTION" in caps. Such as:
junk
junk
junk
DESCRIPTION first entry stuff I want
stuff I want
stuff I want
DESCRIPTION next entry stuff I want
next stuff I want
next stuff I want
DESCRIPTION
etc
etc
What I want to do is take each entry individually, starting with the DESCRIPTION, and push that entry into an array, so at the end I have one array cell for each entry between the DESCRIPTIONS.
Here is my whack at the code so far:
my $filename = "templrep.log";
my $str;
my @templates;
open (FILE,"/tmp/templrep.log" or die ("Cannot open $filename: $1" );
my $arr = <FILE>;
push (@templates, $1) while( $arr =~ m/DESCRIPTION(.*?)DESCRIPTION/gi );
print "@templates\n";
exit 0;
Obviopusly it is not working.
Any help is appriciated.
junk
junk
junk
DESCRIPTION first entry stuff I want
stuff I want
stuff I want
DESCRIPTION next entry stuff I want
next stuff I want
next stuff I want
DESCRIPTION
etc
etc
What I want to do is take each entry individually, starting with the DESCRIPTION, and push that entry into an array, so at the end I have one array cell for each entry between the DESCRIPTIONS.
Here is my whack at the code so far:
my $filename = "templrep.log";
my $str;
my @templates;
open (FILE,"/tmp/templrep.log" or die ("Cannot open $filename: $1" );
my $arr = <FILE>;
push (@templates, $1) while( $arr =~ m/DESCRIPTION(.*?)DESCRIPTION/gi );
print "@templates\n";
exit 0;
Obviopusly it is not working.
Any help is appriciated.