It looks like you are trying to build a multipart MIME entity containing the document (because of your use of boundaries) but you haven't got the right type on it. But:

Also, you get $bufsize to 60*57 (any special reason to pick this number 3420?) and you loop as long as it is still equal to 3420, which it always is since you never change it. It will loop forever.

What you need to do is far simpler:

if (open (INHOUD, "$regel")) { binmode INHOUD; print << "EOT1"; Content-Type: application/msword; filename="bw051122.doc" EOT1 while (read(INHOUD, $buffer, 4096) { print $buffer; }; close (INHOUD);

As a bonus, if you always send the same document, you could add Last-Modified and Expires headers to enable the client to cache the result just like if you have been able to do if the web server had served the file directly.


In reply to Re: Showing Word document in browser by Celada
in thread Showing Word document in browser by Ernst

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.