Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!mintaka!bloom-beacon!deccrl!news.crl.dec.com!decvax.DEC.COM!evans From: evans@decvax.DEC.COM (Marc Evans) Newsgroups: comp.lang.perl Subject: Re: I'm lazy, can this be done somehow??? Message-ID: <528@decvax.decvax.dec.com.UUCP> Date: 29 Jan 91 14:29:44 GMT References: <1991Jan26.012646.4937@sdd.hp.com> Sender: news@decvax.dec.com.UUCP Reply-To: evans@decvax.DEC.COM Distribution: na Organization: Synergytics Lines: 31 In article <1991Jan26.012646.4937@sdd.hp.com>, harless@sdd.hp.com (Mike Harless) writes: |> |> |> What I'd like to do is suck up a file into an array, |> read another file to see how many lines I've already read (if any), |> and then grep strings out of what's new. The file of lines may have been |> zero'd out since the last time I read it, so I can't just start |> reading after skipping so many lines. |> |> For example, if I've read a file into the array @lines, and then found |> out that I've already looked at the first 400 lines last time I ran, I'd |> like to do something like: |> |> $[ = 400 ; |> @found = grep(/whatever/, @lines) ; |> |> and only have grep work on the lines after the first 400. I know that |> I could do this by using an index into @lines, but was trying to do |> things elegantly. I've heard rumors that using indices into arrays isn't |> the perl way! :-) Is there something simple that I missed? Shouldn't you be able to do this using the range construct, as in: @found = grep(/whatever/,$lines[400 .. $#lines]); - Marc -- =========================================================================== Marc Evans - WB1GRH - evans@decvax.DEC.COM | Synergytics (603)635-8876 Unix and X Software Contractor | 21 Hinds Ln, Pelham, NH 03076 ===========================================================================