in reply to Re^3: How do I modify a line within the file itself?in thread How do I modify a line within the file itself?
See Re: reading lines into an array for one reason not to use File::Slurp.