in reply to Looking Backward While counting

An often used method for cases like this is to redefine the input record separator $/ (default value is \n) to the separator of the data chunks, in your case "##Flag##\n". Then each line you read will be a string containing the lines after the Flag. Now split on newline and process the individual lines or the whole string with regexes. For example:

local $/="##Flag##\n"; open my $fh, "<", $filename or die $!; while (my $chunk= <$fh>) { my @lines= split /\n/,$chunk; my ($firstvalue)= $lines[0]=~m/:(d+)/; ...