Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: print line 5 lines previous to comaprison line!

by marcink (Monk)
on Jun 07, 2001 at 20:57 UTC ( [id://86653]=note: print w/replies, xml ) Need Help??


in reply to print line 5 lines previous to comaprison line!

Hi,

this code seems to do the trick quite effectively:

while (<>) { $a[$i++%6] = $_; print $a[$i%6] if /match/; }

Just change the if condition to something reasonable.

-mk

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://86653]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-19 16:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found