1. HTML form passes through parameters to CGI script
2. CGI opens file (new.txt)
3. reads first line of file
4. removes that line from the script
5. closes file
6. opens another file (old.txt)
7. append new record using record read from first file, plus some of the form items from the HTML
8. closes this second file
9. outputs to HTML details posted into second file
I'm across all of these, except for point 4, where I want to remove a line from the original file prior to closing it.
Any suggestions would be welcomed...
Either way, it's a sequential file horse/cart syndrome. To delete the previous line of any file, you'll have to rewrite the file.
That can be done two ways:
copy the remaining lines to a new file, then delete the orginal, then rename the new one.
Or, read in the entire file into memory, and rewrite it with the updated data that leaves out the first line.
[edited by: Brett_Tabke at 10:57 am (utc) on Mar. 15, 2003]
I was thinking that I can easily grab the first line by using :-
$record = <filehandle>
Can I then use
@ecords = <filehandle>
to grab the whole file, then use a loop to write back from line two (which I think perl sees as record 1) onwards
Thanks for your help..