Re: Extracting one record from multiple-records textfile
- From: giuseppegallone@xxxxxxxxx (Giuseppe.G.)
- Date: Wed, 28 Nov 2007 14:05:27 -0800 (PST)
On 28 Nov, 01:44, pa...@xxxxxxxxxxxxx (Jeff Pang) wrote:
Hello,
Just show another way to do it.
use strict;
local $/="\n\n";
while(<DATA>) {
next unless /^DOC-START\n(.*?)\nDOC-END$/sm;
my $content = $1;
parse($content);
}
Thank you all for your answers. In particular, Jeff, I'm trying to
use your code.. what does
local $/="\n\n";do?
I've noticed that if there are some newlines between DOC_START, text,
and DOC_END, as in
DOC_START
gfghdfghdfghfgh
DOC_END
by doing
local $/="\n\n\n";
I get output (if I don't do that $content is empty). Can you tell me
why?
Regards Giuseppe
.
- Follow-Ups:
- Re: Extracting one record from multiple-records textfile
- From: John W . Krahn
- Re: Extracting one record from multiple-records textfile
- References:
- Extracting one record from multiple-records textfile
- From: Giuseppe.G.
- Re: Extracting one record from multiple-records textfile
- From: Jeff Pang
- Extracting one record from multiple-records textfile
- Prev by Date: Re: Time Comparison Easier Than I'm Making them
- Next by Date: Re: How to add commas to a number?
- Previous by thread: Re: Extracting one record from multiple-records textfile
- Next by thread: Re: Extracting one record from multiple-records textfile
- Index(es):
Relevant Pages
|