in reply to Re: Batch processing of files
in thread Batch processing of files

Or you can leave it where it is now, and open the file for appending instead of clobbering the file:

open(TMP,">>$tmp") or die "TMP open failed: $!";

See perlopentut for more information.

Update: Further reflection on what is posted would seem to imply this thread is not immediately pertinent to the OP.

Replies are listed 'Best First'.
Re^3: Batch processing of files
by ikegami (Patriarch) on Feb 11, 2010 at 18:30 UTC

    If you wanted to append to an exiting file, I'd still move the open outside of the loop. Why would you want to open the file repeatedly here?

    Anyway, both of our solution are wrong. It shouldn't be moved outside of the loop. I missed the rename originally.

      For the given code, I would not. I also would not open the same file twice in a loop instead of seek, fail to test my opens, or use external input in the statement open(FH,"$file");. But given the combination of "Here's part of the script" with the tendency for some posted scripts to not correspond to actual code, it seems that piece of information is potentially pertinent as is the tutorial.