Most esteemed prior, a humble pilgrim seeks to barge in and benefit from your wisdom.

you should get into the habit of [...] calling close on the filehandle when the file is no longer being used, and always checking open and close for success or failure

I hear your advice, but I don't understand why these are good habits.

I always regarded calling close as superfluous, unless I was either a) going to open the same file again (perhaps with different parameters, perhaps not), or b) concerned that the system itself would run out of file descriptors for open files (or perhaps c) opening pipes rather than files, but I've never done that). What does explicitely calling close -- much less at the very end of a script, with no further code following it -- accomplish?

On the same note, while it's of course always a good idea to check for errors, what would an inability to close a file signify for the script? I assume that the worst that could happen is that the file remains open; if close is not necessary to begin with, as above, this would not be a problem (since not calling close would leave the file open, anyway). Even if an explicit close is advisable, I'd expect that failure would at most warrant a warning in most situations.

But I'm not an experienced monk of Perl. Please enlighten me, brother!


In reply to Re^2: Identifying unmatched data in a database by AppleFritter
in thread Identifying unmatched data in a database by ardibehest

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.