On Wednesday 28 November 2007 14:05, Giuseppe.G. wrote:
>
> On 28 Nov, 01:44, [EMAIL PROTECTED] (Jeff Pang) wrote:
> >
> > 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?

It sets the Input Record Separator to the string "\n\n" instead of the 
default "\n".

perldoc perlvar


> 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?

Because you are changing the Input Record Separator and you have empty 
lines inside the document.  Chose one of the other methods posted.



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to