Re: Printing text between two blank lines

2008-02-22 Thread Jay Savage
On Fri, Feb 15, 2008 at 4:04 PM, <[EMAIL PROTECTED]> wrote: > I've been trying to use regular expressions or some kind of counter > thing, but I can't seem to work this right. I have data in a text file > where the important thing I want to extract is between two blank > lines. That's the only

Re: Printing text between two blank lines

2008-02-21 Thread Gunnar Hjalmarsson
obdulio santana wrote: use strict; use warnings; $_ = join '',; s/^\s*\n(^.+\n)(?=^\s*\n)/print $1/egm; this one is not so bad or, is it?:-) Actually it's rather similar to some of the solutions that were posted previously in this thread. http://www.mail-archive.com/beginners%40perl

Re: Printing text between two blank lines

2008-02-21 Thread obdulio santana
2008/2/20, John W. Krahn <[EMAIL PROTECTED]>: > > Gunnar Hjalmarsson wrote: > > obdulio santana wrote: > >> Please let me know if everything is Ok. > >> > >> @l = ; > >> @nl = map /^\s*\n/?1:0,@l; > >> map { print $l[$_] if ("$nl[$_ - 1]$nl[$_]$nl[$_ + 1]" eq "101" ) } (0 > .. > >> $#nl); > > > > 1

Re: Printing text between two blank lines

2008-02-20 Thread John W. Krahn
Gunnar Hjalmarsson wrote: obdulio santana wrote: Please let me know if everything is Ok. @l = ; @nl = map /^\s*\n/?1:0,@l; map { print $l[$_] if ("$nl[$_ - 1]$nl[$_]$nl[$_ + 1]" eq "101" ) } (0 .. $#nl); 1. It's no longer a tiny version. ;-) 2. It generates a warning. Aren't you using strictu

Re: Printing text between two blank lines

2008-02-20 Thread Gunnar Hjalmarsson
obdulio santana wrote: Please let me know if everything is Ok. @l = ; @nl = map /^\s*\n/?1:0,@l; map { print $l[$_] if ("$nl[$_ - 1]$nl[$_]$nl[$_ + 1]" eq "101" ) } (0 .. $#nl); 1. It's no longer a tiny version. ;-) 2. It generates a warning. Aren't you using strictures and warnings?? 3. I'd u

Re: Printing text between two blank lines

2008-02-20 Thread obdulio santana
2008/2/20, Gunnar Hjalmarsson <[EMAIL PROTECTED]>: > > obdulio santana wrote: > > I offer you, a tiny version , > > > > @ll=split /^\s*\n/m,join '',; > > print for @ll[1 .. $#ll - 1] ; > > > > That code does not meet the OP's specification. Please consider a file > whose data looks like this: > >

Re: Printing text between two blank lines

2008-02-20 Thread Gunnar Hjalmarsson
obdulio santana wrote: I offer you, a tiny version , @ll=split /^\s*\n/m,join '',; print for @ll[1 .. $#ll - 1] ; That code does not meet the OP's specification. Please consider a file whose data looks like this: pri dfsdfsa first asdf asdf asdf second last ass sad -- Gunnar Hjalmar

Re: Printing text between two blank lines

2008-02-20 Thread obdulio santana
I offer you, a tiny version , @ll=split /^\s*\n/m,join '',; print for @ll[1 .. $#ll - 1] ; __END__ pri dfsdfsa dfasdf asdf first second last ass sad sas d Maybe this helps somebody. Thaks Perl's folks.

Re: Printing text between two blank lines

2008-02-17 Thread Dr.Ruud
Gunnar Hjalmarsson schreef: > Dr.Ruud: >> Gunnar Hjalmarsson: >>> PlagueMagazine: I have data in a text file where the important thing I want to extract is between two blank lines. >>> >>> Assuming the data has been slurped into $_ : >>> >>> print "$1\n" while /\n\n(.+)(?=\n\n)/g;

Re: Printing text between two blank lines

2008-02-16 Thread Gunnar Hjalmarsson
Dr.Ruud wrote: Gunnar Hjalmarsson schreef: [EMAIL PROTECTED]: I have data in a text file where the important thing I want to extract is between two blank lines. Assuming the data has been slurped into $_ : print "$1\n" while /\n\n(.+)(?=\n\n)/g; Or /\n[[:blank:]]*\n(.+)\n[[:blank:]]*\

Re: Printing text between two blank lines

2008-02-16 Thread Dr.Ruud
Gunnar Hjalmarsson schreef: > [EMAIL PROTECTED]: >> I have data in a text >> file where the important thing I want to extract is >> between two blank lines. > > Assuming the data has been slurped into $_ : > > print "$1\n" while /\n\n(.+)(?=\n\n)/g; Or /\n[[:blank:]]*\n(.+)\n[[:blank:]]*\

Re: Printing text between two blank lines

2008-02-16 Thread Gunnar Hjalmarsson
[EMAIL PROTECTED] wrote: I've been trying to use regular expressions or some kind of counter thing, but I can't seem to work this right. I have data in a text file where the important thing I want to extract is between two blank lines. That's the only systematic way to find the useful lines. So,

Re: Printing text between two blank lines

2008-02-16 Thread Paul Johnson
On Fri, Feb 15, 2008 at 01:04:24PM -0800, [EMAIL PROTECTED] wrote: > I've been trying to use regular expressions or some kind of counter > thing, but I can't seem to work this right. I have data in a text file > where the important thing I want to extract is between two blank > lines. That's the o

Printing text between two blank lines

2008-02-16 Thread PlagueMagazine
I've been trying to use regular expressions or some kind of counter thing, but I can't seem to work this right. I have data in a text file where the important thing I want to extract is between two blank lines. That's the only systematic way to find the useful lines. So, it'll go "blank line, impo