Re: Extracting one record from multiple-records textfile



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

.



Relevant Pages

  • Re: Extracting one record from multiple-records textfile
    ... use strict; ... In particular, Jeff, I'm trying to ... I get output (if I don't do that $content is empty). ... Because you are changing the Input Record Separator and you have empty ...
    (perl.beginners)
  • Re: Perl Peeves
    ... use strict; ... No, special false is sticky. ... print 0 + $empty; ...
    (comp.lang.perl.misc)
  • Re: While query
    ... || Hash: SHA1 ... || Oops--this won't actually empty the array as the various pop-based ...
    (comp.lang.perl.misc)
  • RE: Replace update year in date
    ... If your dates are in column A and column B is empty, ... "Jeff C" wrote: ... format and I am using Excel 2003 in XP Pro. ... Can someone suggest a way of correcting this? ...
    (microsoft.public.excel.misc)
  • Re: way to get username & domainname?
    ... > These variables were empty. ... use strict; ... use CGI qw; ...
    (comp.protocols.kerberos)