Hi perlmonk, I am working on translating input for a book from Spanish to English. Sounds easy, but the problem is that this is a specialized book containing plant descriptions in technical botanical terms. So normal translators like imbedded in WORD, Google, etc do not work well. They generate so many errors in the technical descriptions of the plants they are not worth using. I know the translations for words and phrases, but I'd like to automate them to make my job easier. So, I wrote some perl code to search for the words and phrases and replace those with my translations. Problem is that normal read/write in perl does not result in a readable MS WORD (.doc) file as output; even if it is labeled as .doc. I can copy the text to a .txt file, then run my translator on it, but I lose all the formatting in WORD. So, I came across your subroutine in this post (thank you very much), but I'm not expert enough in perl to understand if it will do what I want. I want to do simple text substitution while preserving the WORD formatting in the .doc file. Is that what this subroutine does? If so, where do I put the words and phrases I am searching for and their corresponding translations? Here is some code from my perl program to show the types of substitutions I'm trying to do: # Specific word & phrase translations s/en floración alcanza/flowering/g; # change ONLY FIRST instance of de largo to tall, remainder get changed to long s/de largo/tall/; s/de largo/long/g; # remaining word translations go here s/de ancho/wide/g; s/numeroso/numerous/g; s/denso|densa/dense/g; s/roseta/rosette/g; s/extendida/extended/g; s/ápice/apex/g; I would appreciate any assistance you can provide me. Many thanks, Jerry

In reply to Re: A Solution to the edit Word documents with Perl problem by JerryR
in thread A Solution to the edit Word documents with Perl problem by merrymonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.