in reply to Regular Expressions
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).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
#!/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"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Regular Expressions
by Adam (Vicar) on Aug 14, 2000 at 21:09 UTC |