Regular expression over multiple lines issues
- From: glenn.pringle@xxxxxxxxx (Glenn.Pringle@xxxxxxxxx)
- Date: Thu, 27 Sep 2007 21:44:12 -0000
Hello,
I'm having a problem with a regular expression in some code that I
inherited.
I'm reading from a file and looking for certain parameters (mrn, enc,
date, report_subtitle).
The file looks like this:
%%start
%mrn%02333699
%fac%A
%gpi%
%enc%9720100004
%date%07/07/2007^14:29
%report_type%amit
%report_subtitle%OCR (nut
%phys_id1%GLENN
%phys_id2%RAJPAL
%%Pages: 5
%!PS-Adobe
%%Title: (orderNotes_1)
%%CreationDate: 09/11/07 14:29
%%For: System Man PRINGLE, GLENN O
showpage
%%PageTrailer
end
%%Trailer
%%thisWasThePreviousStart
%mrn%02333699
%enc%0720100004
%date%09/30/2007^23:59
%report_type%PCM
%report_subtitle%Order Confirmation Report (nut
%phys_id1%PRINGLE
My problem is that the regular expression is only displaying the first
item (mrn) but it won't display the others (enc, date,
report_subtitle)
My code is on the following line
#!/usr/bin/perl
#open(FILE, "3688001.ps");
open(FILE, "1234567.txt");
while ($buf = <FILE>) {
#print "$buf\n";
if ($buf =~ m/\%mrn\%(\d+).+
\%enc\%(\d+).+
\%date\%
(\d{1,2})\/
(\d{1,2})\/
(\d{1,2})\^.+
^\%report_subtitle\%(.+)\(
/xms) {
#####################################################################
## debug messages for matches
#####################################################################
print "HERE --> 1=<$1>\n" if (defined($1));
print "HERE --> 2=<$2>\n" if (defined($2));
print "HERE --> 3=<$3>\n" if (defined($3));
print "HERE --> 4=<$4>\n" if (defined($4));
print "HERE --> 5=<$5>\n" if (defined($5));
print "HERE --> 6=<$6>\n" if (defined($6));
print "HERE --> 7=<$7>\n" if (defined($7));
}
}
1;
I would appreciate if anybody can tell me what I'm doing wrong or
missing.
Thanks,
Glenn Pringle
.
- Follow-Ups:
- Re: Regular expression over multiple lines issues
- From: John W. Krahn
- Re: Regular expression over multiple lines issues
- From: Gunnar Hjalmarsson
- Re: Regular expression over multiple lines issues
- Prev by Date: Re: Strange debugging question...
- Next by Date: Extracting file name from full name
- Previous by thread: Installing perl-5.8.8
- Next by thread: Re: Regular expression over multiple lines issues
- Index(es):