This old node reminded me of an anecdote that happened a few years ago. There was this CGI script I inherited that was supposed to send feedback from a web form - in other words, a really simple affair. The customer complained that they kept losing feedback messages sent with the form: their customers followed up on the feedback wondering why nothing happened, and found out their feedback hadn't been received in the first place.

When I looked at the script, the problem was obvious: it did the equivalent of

if(open MAIL, "|/usr/lib/sendmail") { print MAIL <<EOF; content of form EOF } else { print "error message"; }
...end of script.

One close later, the customer was happy... Seems that the script did manage to send the message in some circumstances (probably when the print happened to take place in conjunction with a buffer flush), which mislead the the original author.

The lesson: "good enough" isn't. Even when it appears to work.


In reply to Close your filehandle - a simple fix for a cgi script by jsiren

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.