Steve Massey wrote: > > I hear what your saying, but for this snippet I just want to > cycle through the list, checking the number is correct either > being 3or4 spaces between them, a print out at the end would > be fine. My real data, has ifo on lines in between numbers, but > the count between each number will be either 3 or 4. In reality > if it failed the number check I will break out into a sub- > routine. > > My problem is working out the loop required to achieve this, I > have been on and off hacking at this for a week, each variation > not quite getting there.
Then I misunderstood your original purpose. Are you verifying the structure of the file or processing its contents? James is right, that the first task is to defined how the lines with sequence numbers differ from the intervening 'blank' lines which you now say contain information. Assuming that your sequence number lines are purely numeric, the code below may help. Cheers, Rob use strict; use warnings; my $info; my $sequence = 0; while (<DATA>) { chomp; # Remove record terminator s/\s+$//; # and trailing whitespace s/^\s+//; # and leading whitespace # If the record is empty or contains non-numerics # then it's an information line # if (length == 0 or /\D/) { $info++; die "Too many information lines" if $info > 4; } else { my $value = $_ + 0; # Force to an integer value die "Sequence numbers out of order" unless $value == $sequence + 1; $sequence = $value; $info = 0; } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]