Reading the whole file into an array is definitely the easiest solution, but if you have a *LARGE* file, that might be a problem if you don't have a lot of memory on that machine. Alternatively you could
* open your input file for reading - with the "<" operator
* open an output file for writing - with the ">" operator
1. read your input file, line by line
- if the line is good and you want to keep it,
then write the line to the output file
- if the line is bad and you don't want to keep it,
then do NOT write the line to the output file
2. after the input file has been processed, close both the input file *AND* the output file, and then open the output file with the ">>" append operator. Then write whatever lines you want to append to the same output file.
3. You now have an output file that contains everything you want. If you want, you can rename that to the original input file - if you want to do this, I'd recommend using the File::Copy module - it makes moving or renaming a file very easy.
Hope this helps.
Hardy Merrill
Mission Critical Linux, Inc.