in reply to problem with deleting a row

Provided that your data is "not too large", Tie::File allows you to treat a file like an array.

Removing a line would then be mostly a judicious application of splice to that array.