JavaBloggs
asked on
Appending to a file...
I am currently using a perl script to store form data on a server, it keeps all the data by first opening the file and reading out all the data then printing it all back in, plus the new line at the bottom... (very sad I know...) like this:
open(BUFFER,"<$MBUKstor") or explode ("Cannot open $MBUKstor at line 25 - $!");
push @lines, <BUFFER>;
close(BUFFER);
open(STORE,">$MBUKstor") or explode ("Cannot open $MBUKstor at line 29 - $!");
foreach $line (@lines) {
print STORE "$line\n";
}
print STORE "$FORM{'name'} |:| $FORM{'email'} |:| $FORM{'postcode'} |:| $FORM{'conly'}\n";
close(STORE);
But I want to just print the new line at the end of the file, what is the code to append to the end of the file???
Regards
JB
open(BUFFER,"<$MBUKstor") or explode ("Cannot open $MBUKstor at line 25 - $!");
push @lines, <BUFFER>;
close(BUFFER);
open(STORE,">$MBUKstor") or explode ("Cannot open $MBUKstor at line 29 - $!");
foreach $line (@lines) {
print STORE "$line\n";
}
print STORE "$FORM{'name'} |:| $FORM{'email'} |:| $FORM{'postcode'} |:| $FORM{'conly'}\n";
close(STORE);
But I want to just print the new line at the end of the file, what is the code to append to the end of the file???
Regards
JB
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks again