in reply to Counting lines matching a certain pattern following a select word

This is not a code writing service. I'll just give you the central part of a possible algorithm and leave it to you to fill the gaps (opening the files, closing them, etc.). This is just the basic idea, untested:

my ($current_frame, $count); while (<$INFILE>) { if (/^(Frame:\s+\d+)/) { print "$current_frame $count \n" if defined $current_frame; $current_frame = $1; $count = 0; elsif (/^C\d+) { $count ++; } } print "$current_frame $count \n"; # prints last group
  • Comment on Re: Counting lines matching a certain pattern following a select word
  • Download Code