in reply to replacing while keeping the position of the element in the file
Then just do a global replace on the second file:my %sentence_codes = map { /(.*)_(.*)/ && ($1,$2) } split $codefile;
I've no idea if this is what you wanted, but that's what I read into it. (This is all pseudo-code, really - you'd need to map the first file one line at a time)$sentence_file =~ s/(\w['-]\w?)|[?:;]/$&.'_'.($sentence_codes{$&} || ' +unknown')/eg;
|
|---|