There's more than one way to do things | |
PerlMonks |
Re^2: Grab 3 lines before and 2 after each regex hit (sliding window)by LanX (Saint) |
on Apr 25, 2014 at 20:31 UTC ( [id://1083855]=note: print w/replies, xml ) | Need Help?? |
> This is a fairly primitive way to do it: using a sliding window (safer with huge streams)
-->
Cheers Rolf ( addicted to the Perl Programming Language)
updatemaybe more elegant
UpdateOh the latter (more elegant) approach has a clear advantage, if you want to avoid overlapping results you just need to empty the window after a match and it gets automatically refilled. :)
In Section
Seekers of Perl Wisdom
|
|