perlquestion
Polyglot
Greetings to all,
<p>
I asked in the chat window several days ago about how to accomplish this, and tye provided me a good answer using map and sort. Unfortunately, my laptop crashed shortly thereafter, and I lost his answer. (That'll teach me, ha!) However, there are a couple of complicating factors that tye may not have addressed even then, and I'm looking for wisdom on a succinct <i>and</i> safe way of accomplishing this.
<p>
Here's what I have:
<p>
<ol>
<li>A file containing a tab-delimited list of words to exchange for modern spellings/equivalents, followed by a third column for any stopwords which should not have substitutions done in them.
<li>A file containing a list of files in which substitutions must be made.
<li>Over a hundred such files needing to be updated.
<li>The target language is Asian, where 1) there are no spaces between words; and 2) the encoding will be UTF-8. (This is significant, because any regexp must be sensitive to this, or it will fail.)
</ol>
Here's an "English-ised" example of the words list file:
<p>
<table cellspacing="5">
<tr><td>WORD</td><td>REPLACEMENT</td><td>STOPWORDS</td></tr>
<tr><td>score</td><td>twenty</td><td>fourscore,scored,scores</td></tr>
<tr><td>core</td><td>center</td><td>encore,coregent</td></tr>
<tr><td>centre</td><td>center</td><td> </td></tr>
<tr><td>travelled</td><td>traveled</td><td> </td></tr>
<tr><td>hasn't</td><td>has not</td><td> </td></tr>
<tr><td>Johann</td><td>John</td><td>Johannesburg</td></tr>
</table>
<p>
So, what I need to do is substitute each word in the first column for the word(s) in the second column, <i>except</i> where the word in the stopwords column is matched. While this seems like a simple scenario, I'm struggling to wrap my brain around it. I'm just beginning to grasp the concepts of map and join, and their syntax, but would much appreciate some ideas for how to accomplish this.
<p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-644375">
<p>Blessings,
<p><i>~Polyglot~</i>
</div></div>