note
Discipulus
I was sure it would be easier with [doc://splice] but i falled in the 'modifying an array while iterating over it' pitfall..<BR>
To avoid a copied data I needed to undef some value and grep for defined values when printing the copy output.. anyway it works.<BR>
I have modified the DATA a little to be easier to follow
<CODE>
use strict;
use warnings;
my @lin = <DATA>;
map {
$lin[$_] and $lin[$_] =~/XXXXX/ ?
$_ == 0 ? splice @lin,0,2,undef,undef :
$_ == $#lin ? splice @lin,$_-1,2,undef,undef :
splice @lin,$_-1,3,undef,undef,undef :
1
} 0..$#lin;
print "$_" for grep {defined} @lin;
__DATA__
XXXXX
Aoooo
XXXXX is my name
Boooo
11111
22222
33333
Coooo
XXXXX is what I play
Doooo
44444
# OUTPUT
11111
22222
33333
44444
</CODE><BR><BR>L*<BR>
<div class="pmsig"><div class="pmsig-174111">
There are no rules, there are no thumbs..<BR>
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
</div></div>
1153137
1153142