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, > > ===============Data==================== > > 1 (5) ##consider this line number known,, 23 lines to next > > [snip] > > 2 (1) ## this is second set of data, 23 lines to next set > > [snip] > > 3 (7) ## third set , 22 lines to next set > > [snip] > > 4 (3) ## forth set > > [snip]
This works with the data supplied: #!/usr/bin/perl use warnings; use strict; use constant LINES => 22; use constant SETS => 4; my $record = 1; my $count = LINES; my @data; while ( <> ) { if ( $count++ >= LINES and /^$record\b/ ) { die "Record error: record number $record\n" if $record++ > SETS; $count = 1; push @data, $_; } else { $data[ -1 ] .= $_ if @data; } } print '-' x 60 . "\n"; print join '-' x 60 . "\n", @data; print '-' x 60 . "\n"; __END__ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]