besides the two approaches given above, you could give
Tie::File by
Dominus a try. It would allow you to manipulate a text file as a perl array (each file record, line per default, corresponding to an element of the array) without loading the whole file into memory, so it is specially useful for large files. Also useful when modifying files...
hope this helps,