problem getting "/n" to a file

K

kvanka

Hi:

I am trying to append an existing file with some text and want to add a
"\n" in the end so that the next append will go on to a new line (I
need content to be on new line whenever appended).

But, seems perl is adding it to the same line no matter what I did...

Help greatly appreciated...

Here's code:

sub updateapplied()
{
open (THEFILE, ">>../files/info.csv") || Error_open ();
print THEFILE $studentf, "\n"; close(THEFILE);
}

I alternatively tried:
print THEFILE "$studentf\n";
print THEFILE "\n$studentf\n";

info.csv ends up like this (after 3 excecutions):
111111111111111111111

where $studentf == 1111111

I want it to store it as:
1111111
1111111
1111111

I hope I am clear with example....
 
D

Dr.Ruud

(e-mail address removed) schreef:
info.csv ends up like this (after 3 excecutions):
111111111111111111111

Did you delete the file before testing? Maybe you are just appending
empty lines to existing contents.

Please read the Posting Guidelines first.

Come back with short complete runnable code, expressing your problem.

Don't forget to have these at the start:

use strict;
use warnings;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top