R
Robert TV
I seem to be experiencing something odd when writing data to a file ... I
say because I have not had a problem like this before. I have 3 values to
write to the file ... I want each value on its own line. I use this code
(not working correctly)
#create the file
open (FILE,">>datafile.inc") or die "Can't open file: $!";
close(FILE);
#write data to file
open (FILE,">>datafile.inc") or die "Can't open file: $!";
print FILE "$value1\n";
print FILE "$value2\n";
print FILE "$value3\n";
close(FILE);
After this operation is complete, I can find the file on the server. When I
open it, all data is on a single line. For some reason, it's ignoring my
"\n"s. I also tried this:
#create the file
open (FILE,">>datafile.inc") or die "Can't open file: $!";
close(FILE);
#write value1 to file
open (FILE,">>datafile.inc") or die "Can't open file: $!";
print FILE "$value1\n";
close(FILE);
#write value2 to file
open (FILE,">>datafile.inc") or die "Can't open file: $!";
print FILE "$value2\n";
close(FILE);
#write value3 to file
open (FILE,">>datafile.inc") or die "Can't open file: $!";
print FILE "$value3\n";
close(FILE);
Same thing, all data is still on a single line. Funny thing is i've working
with simple flatfile datafiles before without this problem. Maybe my brain
isn't firing correctly right now. I will add this though ... if I replace my
"\n"s with "\r\n"s I get the data on multipul lines ... BUT ... "\r"s screw
up other parts of my code (not shown) Any ideas?
Robert
say because I have not had a problem like this before. I have 3 values to
write to the file ... I want each value on its own line. I use this code
(not working correctly)
#create the file
open (FILE,">>datafile.inc") or die "Can't open file: $!";
close(FILE);
#write data to file
open (FILE,">>datafile.inc") or die "Can't open file: $!";
print FILE "$value1\n";
print FILE "$value2\n";
print FILE "$value3\n";
close(FILE);
After this operation is complete, I can find the file on the server. When I
open it, all data is on a single line. For some reason, it's ignoring my
"\n"s. I also tried this:
#create the file
open (FILE,">>datafile.inc") or die "Can't open file: $!";
close(FILE);
#write value1 to file
open (FILE,">>datafile.inc") or die "Can't open file: $!";
print FILE "$value1\n";
close(FILE);
#write value2 to file
open (FILE,">>datafile.inc") or die "Can't open file: $!";
print FILE "$value2\n";
close(FILE);
#write value3 to file
open (FILE,">>datafile.inc") or die "Can't open file: $!";
print FILE "$value3\n";
close(FILE);
Same thing, all data is still on a single line. Funny thing is i've working
with simple flatfile datafiles before without this problem. Maybe my brain
isn't firing correctly right now. I will add this though ... if I replace my
"\n"s with "\r\n"s I get the data on multipul lines ... BUT ... "\r"s screw
up other parts of my code (not shown) Any ideas?
Robert