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
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
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
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
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
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:
>
>
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
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.
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;
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:]]*\
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:]]*\
[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,
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
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
14 matches
Mail list logo