my ($TEXTIN,$HTMLOUT); my $input2 = $outputfile; my $output2 = "FTFIMS.html"; my @records=(); my $inrecord=0; my $rxRecStart = qr{STORE\d+}; my $rxRecStop = qr{\n\s}; my $recordStr = q{}; #### open $TEXTIN,"<",$input2 || die "Can not open $input2: $!\n"; #### open ($TEXTIN, "<", $input2) || die "Can not open $input2: $!\n"; #### open $TEXTIN, "<", $input2 or die "Can not open $input2: $!\n"; #### open my $TEXTIN, "<", $input2 or die "Can not open $input2: $!\n"; #### my $header = ""; $header .= <$TEXTIN> for 0..1; # record the first two lines for later use while(<$TEXTIN>){ next if m/^\s*$/; # get rid of empty lines if (m{$rxRecStart}){ # do what you need to finish off the previous section # (saving the data) and start the new one } else { $recordStr .= $_; } } # add code here for storing the last section