The problem is that the file is always "complete". It's just that it may be more "complete" a moment later. So if you seek to the end, and then check for EOF as you suggest, it'll probably return true. It won't if the file has actually grown in between the seek and the test, but you may be testing too quickly. As the others suggest, you could include some delay, but there's the risk that the delay won't be enough.

However, if that's your decision... rather than than actually opening the files and making some decision base on the content, why not just look at the timestamp on the files, and consider them complete if they're old enough?

time-(stat $file)[9]
will tell you how many seconds since it was last written (note that you can't use -M, since that's based on the start time of the program, not the current time).

A better option, if you're on a UN*X system would be to use fuser on the file:

system "fuser -s $file"; print $?>>8?"complete":"still open";

--
Tommy
Too stupid to live.
Too stubborn to die.


In reply to Re: Treat a directory as file queue by tommyw
in thread Treat a directory as file queue 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.