| appending to a text file return lines |
wjd4

msg:443245 | 10:23 pm on Oct 12, 2004 (gmt 0) | I am working on a project, trying to add lines to a text file. I am splitting the text file using javascript based on lines, so it is important that the added info is put on a new line. When i try to add to the file using perl, it only puts a box character and then ads the new info on the last line not creating the new line. this is the code that I am using to append to the file. open(DAT, ">>".$data_file) ¦¦ die("not open file!"); print DAT "\n$last_name $first_name ,$year,$email"; close(DAT); as you can see I am using the \n . Is there something else that I should be using, or is there a different way to do that. thanks Will
|
wjd4

msg:443246 | 11:42 pm on Oct 12, 2004 (gmt 0) | i was talking to people on yahoo chats, and figured out that the new line in windows is \r\n i had used \n and \n\r and neither worked, but this one seemed to do it.
|
volatilegx

msg:443247 | 3:04 pm on Oct 15, 2004 (gmt 0) | Just curious, what text editor are you using to view the file?
|
wjd4

msg:443248 | 12:18 am on Oct 16, 2004 (gmt 0) | notepad, on windows xp
|
SlowMove

msg:443249 | 12:55 am on Oct 23, 2004 (gmt 0) | I don't see any problem with it. I ran the following code and it puts all the data on a new line: #!/usr/bin/perl$data_file = "foo.txt"; $last_name = "Doe"; $first_name = "Jon"; $year = 1963; $email = "jdoe\@foo\.com"; open (DAT, ">>$data_file") ¦¦ die ("not open file!"); print DAT "\n$last_name $first_name ,$year,$email"; close (DAT);
|
|
|