BEGIN { $sep= '' } if( '' eq $sep && 1 < @F ) { ( $sep )= /\Q$F[0]\E(.*?)\Q$F[1]\E/; } #### my $pos= 0; for my $f ( 0..$#F ) { pos($_)= $pos; die if ! m/\Q$F[$f]\E/g; $pos= pos($_) + length($G[$f]) - length($F[$f]); substr( $_, $-[0], $+[0]-$-[0], $G[$f] ); } pos($_)= 0;