in reply to speeding up script that uses filehandles
Try changing your foreach loop to a while loop. The effect of that will be to read the file line-by-line instead of attempting to load the whole thing into memory before processing it.
-Yendor IWeThey HOPE Ride