I don't see where your problem has anything to do with the ordering of opens and closes. More likely the records are not getting written correctly. Your code slurps the contents of the input file as one record into the first element of @array_contents then writes $contents out to the second file without any record delimiters. The code provided does nothing when I run it. Have you verified the contents of your written file using a text editor? Can you provide a snippet of code that behaves as you say?
Two other minor points. You call chdir() inside your foreach(@files) loop. This will only work for absolute path names otherwise the code will try to chdir to a subdirectory from inside a subdirectory. The $count loop displays the first record as a count of 0. While it would be proper to consider this an index of 0, the count should read 1.
In reply to Re^3: Opening a File Twice
by starbolin
in thread Opening a File Twice
by Jamin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |