in reply to Regular Expressions

First, surround any data or code with CODE tags. If I understand you correctly, your data looks something like this:
Header Line One ***-*** 0 0 ***-MBO 0 0 2TO-T/V 0 0 2TO-T/O 0 0 POC-CNU 1285 0 POC-A/M + 0 15567 Header Line Two ***-*** 0 0 ***-MBO 0 0 2TO-T/V 0 0 2TO-T/O 0 0 POC-CNU 1285 0 POC-A/M + 0 15567
Although you do not specify, I'll also assume that the header lines alternate between 'one' and 'two', and you just want to make sure that these don't repeat (that is, they continue to alternate).

Here's what I'd try:
#!/usr/bin/perl -w use strict; # variable to hold the previous header my($header); foreach (<>) { if (/^Header Line (\S+)$/) { die "Error - header repeated in line $.\n" if ($header && $header +eq $1); $header = $1; next; } if (/^[\w\*\/]{3}-[\w\*\/]{3}/) { # do whatever processing on the line print "Got a matching line...\n"; } }

Hope that helps,
Shendal

Update: Darn. Looks like I got your data wrong - or zzamboni did (grin). All the more reason to use CODE tags.

Replies are listed 'Best First'.
RE: Re: Regular Expressions
by Adam (Vicar) on Aug 14, 2000 at 21:09 UTC
    You can see the intended format of a post by viewing the html source that your browser is attempting to display.