title: Changing words in text files using multiple dictionaries
body: <p>I have a bunch of files which need to be translated using custom dictionaries. Each file contains a line indicating which dictionary to use. Here's an example:</p>
  
  <pre><code>*A:
  !
  =1
  *&gt;A_intro
  1r
  =2
  1r
  =3
  1r
  =4
  1r
  =5
  2A:maj
  *-
  </code></pre>
  
  <p>In the file above, <code>*A:</code> indicates to use <code>dictA</code>.</p>
  
  <p>I can translate this part easily using the following syntax:</p>
  
  <pre><code>sed -f dictA &lt; myfile
  </code></pre>
  
  <p>My problem is that some files require a change of dictionary half way in the text. For example:</p>
  
  <pre><code>*B:
  1B:maj
  2E:maj/5
  2B:maj
  2E:maj/5
  *C:
  2F:maj/5
  2C:maj
  2F:maj/5
  2C:maj
  *-
  </code></pre>
  
  <p>I would like to write a script to automate the translation process. Using this example, I would like the script to read the first line, select <code>dictB</code>, use <code>dictB</code> to translate each line until it reads <code>*C:</code>, select <code>dictC</code>, and then keep going. </p>