That code is going to count the number of newline characters in your file, which in the case of a Word doc is next to meaningless.

To do this right, you'll have to open the file with Word itself (using Win32::OLE), and then either use the Document properties, or walk through the document a paragraph or word at a time, using one of the iterators over the document. You can get an estimate from that, but not a real "line count" -- that depends on how the document's rendered by the printer, not the document itself. Hmm, you may be able to use the Print Preview.... /me slaps self

I've used the Win32 modules for stuff like this, but never with Word, so I can't vouch for how well this will work. But in general you'll need a decent understanding of the Word object model (start the Visual Basic Editor and bring up the Object Browser).

And, yes, it's very tedious programming....


In reply to Re: Number of lines and characters by VSarkiss
in thread Number of lines and characters by Anonymous Monk

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.