To follow up on my earlier message a second time, "$buffer[$N]" should 
have been
"$buffer[$. - $n]":

    my $N = 10;
    my $regex = shift;
    my @buffer = ();

    while (<>) {
        push(@buffer, $_);
        next if $. < $N * 2;
        if ($buffer[$. - $N] =~ /$regex/) {
            print "@buffer\n";
            shift @buffer;
        }
    }


-- 
John Abreau / Executive Director, Boston Linux & Unix 
ICQ 28611923 / AIM abreauj / JABBER [EMAIL PROTECTED] / YAHOO abreauj
Email [EMAIL PROTECTED] / WWW http://www.abreau.net / PGP-Key-ID 0xD5C7B5D9
PGP-Key-Fingerprint 72 FB 39 4F 3C 3B D6 5B E0 C8 5A 6E F1 2C BE 99

"The early bird catches the worm, but the second mouse gets the cheese."




-- 
John Abreau / Executive Director, Boston Linux & Unix 
ICQ 28611923 / AIM abreauj / JABBER [EMAIL PROTECTED] / YAHOO abreauj
Email [EMAIL PROTECTED] / WWW http://www.abreau.net / PGP-Key-ID 0xD5C7B5D9
PGP-Key-Fingerprint 72 FB 39 4F 3C 3B D6 5B E0 C8 5A 6E F1 2C BE 99

"The early bird catches the worm, but the second mouse gets the cheese."


Attachment: msg01886/pgp00000.pgp
Description: PGP signature

Reply via email to