in reply to Re: Searching data file
in thread Searching data file
(This actually strips off the <ref> and </ref> tags; if you want to preserve them, reverse the order of the lines in the while loop.)sub readrec { my $line; my $inrec; my $rec; while (defined($line = <FH>)) { last if $line eq "</ref>\n"; $rec .= $line if $inrec; $inrec ||= $line eq "<ref>\n"; } $rec; }
You could also parse the record as you read it, but to search any of the fields, its probably more convenient to return just a string to match against, and split it up into the components if it matches.
(BTW, the OP's match statement doesn't look
as if it would work at all.)
(updated to remove comment about match based on misunderstanding)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Searching data file
by sauoq (Abbot) on Nov 03, 2003 at 00:22 UTC | |
|