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
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/