
Cure
User
Apr 22, 2000, 11:06 PM
Post #3 of 3
(210 views)
|
|
Re: Open file 2 times writing then append
[In reply to]
|
Can't Post
|
|
Hi You are NOT appending here, you are opening a fresh empty file. open (NEWREG, ">$basepath$regdir/$form{'ALIAS'}.dat") or die "can't append to file: $!"; ################# Now you are appending the following to what you wrote to the new file earlier. open(REGFILE, ">>$basepath$regdir/$form{'ALIAS'}.dat") or die "can't append to file: $!"; ##########################3 The append works for me. The following test script: #!/usr/bin/perl $np = 'data1'; $nnn = 'data2'; $pnn = 'data3'; open (NEWREG, ">test.dat") or die "can't append to file: $!"; print NEWREG "$np\n$nnn\n$pnn\n"; close NEWREG; open(REGFILE, ">>test.dat") or die "can't append to file: $!"; print REGFILE "test\[\]ITEM\[\]RATES\n"; close REGFILE; Did you expect the first open to be an append? Then use >> instead of >. Cure [This message has been edited by Cure (edited 04-23-2000).]
|