in reply to replacing while keeping the position of the element in the file
I think you might want something like this:
Though that won't strip any newlines. Doing so isn't difficult.my %xlate; # open DOC1 here while (<DOC1>) { chomp; my($word_part) = split /_/; $xlate{$word_part} = $_; } # open DOC2 here while (<DOC2>) { s/(\S+)/$xlate{$1}/ge; print; }
|
|---|