in reply to Substitute array value in regular expression
Looks like you are trying to operate on 2 lines at a time (at least that's the effect of your while(<DOC>){$.=<DOC>). Is this correct?
I don't see anything wrong with the rest of the code (modulo others suggestions of using join or qr to avoid the inner loop or recompiling the pattern each time).
Is it possible you have special characters in @final_array that you want to match literally? If so, you need s/\Q$value\E/... or to preprocess your array (once, not in the while loop) with $_ = quotemeta($_) for @final_array or something similar.
|
|---|