This does not answer your question (the previous answers should give enough information anyway), but I thought you might find interesting a third method (it's always useful to have many tricks in the bag): try
Tie::File, by
Dominus. It lets you manipulate a file as a regular perl array (each file record -- one line is the default -- corresponding to an array element) without loading the whole file into memory, so it is particularly good when dealing with big files.
hope this helps,