Just a quicky question. How would I change one line in a file? I have a comment feature on this journal script I run, and I want to make it possible for editing of comments. I store the messages in a file for that journal entry, and have each comment on a new line, and the various info such as name, date, etc. being split by pipestems (|). So that being said, how would I be able to keep the rest of the file, but reprint the new info for that one line. I know how to splice, but I can't figure out how to reprint that new line if it is in the middle of a file.
[ March 08, 2001: Message edited by: Scud Muffin ]
open FILE,"+>/path/to/file"; @myfile = ; $myfile[$linenumber_you_want_to_change - 1] = "what you want that line to be"; foreach $line(@myfile) { print FILE "$line"; } close (FILE);
Q for Mark: can you skip the foreach and just print the array directly? I assume so, but decided to be cautious...
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.