On Tue, 8 Mar 2005 15:26:28 -0500, Dave Gray <[EMAIL PROTECTED]> wrote:
> > > Something like (untested):
> > >
> > > my (@lines, $num) = ((), 4);
> > > while (<INPUT>) {
> > >   push @lines, $_;
> > >   shift @lines if @lines == $num+1;
> > >   print 'lines '.($.-$num+1).' to '.($.)." match\n"
> > >     if join('',@lines) =~ /regex goes here/;
> > > }
> > >
> >
> > That assumes that the pattern being searched for will begin 4n lines
> > from the beginning of the file, but just because we're looking for
> > four lines doesn't mean the file is written in four line chunks.  In
> > fact, it probably isn't.
> 
> Er, no it doesn't. Read it again. It's a rolling n-line chunk of the file.
> 

You are correct, I misread.

--j

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


Reply via email to