With Tie::File you get to use conveniences such as splice, push, shift, and so on.
Another method is to open the input file, open an output file, read the input file line by line, and as you read it, write line by line to the output file, of course skipping output for those lines you wish to drop (next is great for that).
Once you've finished reading the input and writing the output file, unlink the input file, and rename the output file to the same name as the original input file.
That's pretty much what the -i command line switch implements behind the scenes.
|