Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

appends a file TWICE every time?

Status
Not open for further replies.

weatherboy

Programmer
Sep 12, 2002
1
US
Trying to set up a flat-file database, and each time I append to it, the info is added twice. Here's the code:

# test if the 'save' button was clicked;
if($note_adder eq "SAVED"){
open(DAT, ">>$data_file") || die("FAILED: $!");
print DAT "$into1\|$time0\|$info2\|$info3\n";
close (DAT);
}
 
The code looks fine. Sounds like this block of script, or the section it's in, is being called twice (perhaps it's in a sub that's being called ...). Either find out where that is, or how it's being called and try to remedy that.

Alternatively, if this is the only thing the script needs to do when $note_adder is 'saved', you could try adding
Code:
exit;
after the
Code:
close(DAT);
line, ending the script after the first run through.

If that's doesn't help, I think we'd need to see some more of the code...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top