in reply to check for contiguous row values
Try it this way (pseudo-code so you can get the practice writing the Perl):
For summarize(@subgroup), I don't quite get from your question what the processing you do is (record first and last in group and sum fields?). Anyway - your gap finding is missing, and you need to add logic for the two different kinds of gaps before you can summarize.my @captured; While I still have records: Is this a break line? Y - check_for_more_breaks(@captured) @captured = () next item N - save line to @captured Anything left in @captured? check_for_more_breaks(@captured) sub check_for_more_breaks: # Your actual processing here is unclear; I've taken # a guess at it. my @subgroup; my $last_sequence_number; for each line: extract the fields is last_sequence number defined? N - save this one as the last sequence number save the current data of interest in @subgroup next else is there a gap in the sequence numbers? Y - summarize(@subgroup) @subgroup = (); save current sequence number as last save the current data of interest next
|
|---|