How do I change one line in a file/delete a line in a file/insert a line in the middle of a file/append to the beginning of a file?
Those are operations of a text editor. Perl is not a text editor. Perl is a programming language. You have to decompose the problem into low-level calls to read, write, open, close, and seek. Although humans have an easy time thinking of a text file as being a sequence of lines that operates much like a stack of playing cards — or punch cards — computers usually see the text file as a sequence of bytes. In general, there’s no direct way for Perl to seek to a particular line of a file, insert text into a file, or remove text from a file. (There are exceptions in special circumstances. You can add or remove at the very end of the file. Another is replacing a sequence of bytes with another sequence of the same length. Another is using the $DB_RECNO array bindings as documented in the DB_File manpage. Yet another is manipulating files with all lines the same length.) The general solution is to create a temporary copy of the text file with the changes you want, then copy that over the ori