Re: need to go back three lines after a match

From: Michael Budash (mbudash_at_sonic.net)
Date: 10/04/03


Date: Fri, 03 Oct 2003 22:55:57 GMT

In article <3f7df944_1@news.iprimus.com.au>,
 Andrew Rich <vk4tec@hotmail.com> wrote:

> Howdy,
>
> I have a need to do this :-
>
> 1. find a match
> 2. go back three lines
> 3. read out lines 1 2 3
>
> eg
>
> apples
> bannanas
> oranges
>
> match on oranges
>
> back up three lines, output three lines
>
> apples
> bannanas
> oranges
>

how bout this:

while (<DATA>) {
    push @queue, $_;
    shift @queue if @queue == 4;
    if (/oranges/) {
        print @queue;
        last;
    }
}
__DATA__
pears
apples
bananas
oranges
peaches

-- 
Michael Budash


Relevant Pages

  • Re: Androcless accusations of lying
    ... ct is scalar multiple of x, otherwise it may already be squewed or ... Oranges, and apples, if you like. ... Of course, I'm talking about real physics and sanity, not theoretical ...
    (sci.physics.relativity)
  • Re: Question about light clock and derivation of time dilation
    ... >>> Unfortunately, with morons like Androcles and Wilson, ... >> Indeed there are negative time intervals because measuring a time ... > negative apples or negatove oranges, ...
    (sci.physics.relativity)
  • OT: movie-fan rgpers
    ... Who like apples and oranges equally? ... Blues Brothers ... Zatoichi flics ...
    (rec.gambling.poker)
  • Re: ARod is not clutch
    ... season and a small handful of plate appearances in the playoffs ... is mixing apples and oranges. ... are somehow more relevant today than recent history. ...
    (alt.sports.baseball.ny-yankees)
  • Re: macro for coding an id number
    ... "Matthew Kramer" wrote in message ... > 1001 apples USA large red ... > 7771 oranges France small ... > 7772 oranges France medium ...
    (microsoft.public.excel.programming)