in reply to Perl question about manipulation of LDIF file
You may want to have a look at this post Re^2: Grab 3 lines before and 2 after each regex hit (sliding window).
The update shows a generic solution how to parse a sliding window of 6 lines and test the 4th one.
use strict; use warnings; use Data::Dump; my @window; while ( my $line = <DATA> ) { push @window, $line; next if @window < 6; # init if( $window[3] =~ m/[^\d]+\d+/ ){ dd \@window; } shift @window; }
You could easily adapt this to your needs.
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
|
|---|