On Wed, Feb 28, 2001 at 05:16:55PM -0600, mjn wrote:
> Yep, that's the problem. Its likely rudimentary but, how do I get around
> this stupidness on my part? I haven't ever tried multiline pattern
> matching before...
IIRC, your original request looked like you're parsing a file containing
several distinct records with a recognizable pattern (I'll assume it's a line
beginning with "START:") that indicates the beginning of a new record. I
assume that you're only interested in matching data within a single record at
a time.
Based on this, you'll want to read each record in full into a single string,
then run your regex against that string. I would probably (based only on the
impressions and assumptions already stated) use something like:
---
my $record_text = '';
while (<MYFILE>) {
unless (/^START:/) {
# Continuation of record in progress
$record_text .= $_;
} else {
# Found a new record
examine_record($record_text);
$record_text = $_;
}
}
# Last record won't be followed by a 'new record' marker
examine_record($record_text);
sub examine_record {
my $record_text = shift;
if ($record_text =~ /foo.+bar/sm) {
...
}
}
---
(This should be considered to be perl-like pseudocode, as I have not actually
run it.)
--
SGI products are used to create the 'Bugs' that entertain us in theatres
and at home. - SGI job posting
Geek Code 3.1: GCS d? s+: a- C++ UL++$ P++>+++ L+++>++++ E- W--(++) N+ o+
!K w---$ O M- V? PS+ PE Y+ PGP t 5++ X+ R++ tv b+ DI++++ D G e* h+ r y+