Steve Massey wrote:
>
> below is sample of my data, OK forget my simplifying,
> between the data sets the count can vary, either 23 or
> 24, number of data sets is knowm - 4,

That's better! Thanks Steve.

I think this will do what you need, but doesn't check
the number of information blocks. It also doesn't record
the bracketed value after the sequence number, which you don't
mention.

HTH,

Rob



use strict;
use warnings;

my $sequence = 0;
my @info;

while (<DATA>) {

  chomp;          # Remove record terminator

  # If this record looks like
  #
  #    99     (99)
  #
  # then it's the sequence number of a new information block
  #
  if ( /(\d+)\s+\(\d+\)/ ) {

    my $value = $1 + 0;   # Force to numeric
    die "Sequence numbers out of order" unless $value == $sequence + 1;
    $sequence = $value;

    if (@info) {
      print map "$_\n", @info;
      print "--------\n";
    }

    @info = ();
  }
  else {
    push @info, $_;
    die "Too many information lines" if @info > 24;
  }
}


__DATA__

(as in your post)




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to