Well, actually, I was looking for an answer like Perl should guarantee proper closing of the file if the file if the local handle goes out of scope, or otherwise Perl does not guarantee that this happens. Maybe I didn't made myself clear in this respect, but the problem wasn't what to do to avoid this problem (in my case, I simply put a close in the end of the block), but whether this problem (in a correct Perl installation) is supposed to appear at all; for, in case this is something which is supposed to work, but at my colleagues system it occasionally does not work, this means that we have a fundamental problem lurking somewhere on his platform which is well worth investigating. Otherwise, in case it is really undefined behaviour in Perl, but just happens to work *usually*, there is no need to research further.

From my understanding of Perl, I could not decide this question. The link I mentioned in an earlier post seems to suggest that this is well defined behaviour in Perl, but of course this article could also be wrong, or I could have misinterpreted it. So I was hoping that someone would know what exactly happens in Perl if a local filehandle goes out of scope. Given the length of this discussion, this seems to be a dark corner in Perl.

Actually, it maybe has implications to other areas as well. For instance, if I have a local scalar, holding a blessed reference, and this scalar goes out of scope (and there are no accesses to this reference any more); does Perl guarantee then that the DESTROY function of this object will be executed immediately, or could it be that it is called at some later time?

-- 
Ronald Fischer <ynnor@mm.st>

In reply to Re^2: Implicit closing of files by rovf
in thread Implicit closing of files by rovf

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.