Melodius Monks,

Did I just mess up a file processing run?

I have a 1,000,000 line text file to process. The important part of the code is:

open(FILE, $data_file) or die("cannot open file : $data_file $!"); print "<p>opened file $data_file ok\n"; while ($line = <FILE>) { DO A BUNCH OF STUFF WITH THIS LINE } close(FILE);

I start the program via telnet, and use NOHUP so it runs to the end. (NOHUP perl myscript.pl) The "print" statement gets printed out to a nohup.out file, an in my WHILE lopp there's a print statement that outputs the line number it's workig on every 1,000 lines so I know where it is.

Because there are about 1,000 operations to do on each line, it takes a looooooong time to run. It's running on a UNIX server.

In the middle of a run, someone deleted the data_file from the server by ftp.

I thought that using this form of while ($line = <FILE>) read in one line ata time from disk, and that deleting the file during arun would kill the running process, since it could no longer read from it. BUT - I see that my nohup.out file continues to be updated with lines being process. AND "ps U myusername" via telnet says myscript.pl is still running.

Is it possible that it really is still running? Have I misunderstood how ths works? Did it really read a copy of the file into cache or something that allows it to coninue with the file deleted?

Is there hope for me (or am I hopeless?)

Thanks.




Forget that fear of gravity,
Get a little savagery in your life.

In reply to What if FILE deleted during WHILE read-in loop? by punch_card_don

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.