[EMAIL PROTECTED] wrote:
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>) {
Since your regex spans over multiple lines, you can't just read one line
at a time.
local $/ = "end\n";
while (my $buf = <FILE>) {
Read about the $/ variable in "perldoc perlvar".
#print "$buf\n";
if ($buf =~ m/\%mrn\%(\d+).+
\%enc\%(\d+).+
\%date\%
(\d{1,2})\/
(\d{1,2})\/
(\d{1,2})\^.+
Year may have four digits.
(\d{2,4})\^.+
^\%report_subtitle\%(.+)\(
You probably want that to be non-greedy.
^\%report_subtitle\%(.+?)\(
Read about greediness in "perldoc perlre".
/xms) {
<snip>
I would appreciate if anybody can tell me what I'm doing wrong or
missing.
See comments above.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/