Here's one way of using Perl to read Microsoft word documents. I don't have Windows or Word to test—and the post cleverly mentions that solutions like this go out of date rapidly, but doesn't provide any date for the post itself, so I have no idea how old it is. Anyway, this might be enough to get you started. (There's a Win32::Word::Writer module, but, of course, that's the opposite of what you want.)

The simple and glib answer to “Can you re-construct the original Word file?” is “No”. Is it acceptable to convert to some other format instead of plain text? Word itself can save as RTF or HTML, I think; the HTML it generates is pretty awful, but there are programs to tidy up for you. An HTML document will be much more faithful to the original than plain (unformatted) text would be.


In reply to Re: MS Word conversion by JadeNB
in thread MS Word conversion by gibsonca

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.