200720082009
Technical User
Hi,
...
$cotents ='';
...
$newString = 'hello\n';
$cotents .= $newString;
open OUT, ">$FILE" or die "Can not open $FILE for writing :$!";
print OUT $contents;
...
I tried to add a new string (named $newString) with a new line at the end of that string to a string variable ($contents). Then when I tried to write that $contents into an output file. I found the output file actually contains hello\n instead of a 'hello' and a new line. Anybody could help me out how to write a string with a new line to a file?
Thanks.
Mike
...
$cotents ='';
...
$newString = 'hello\n';
$cotents .= $newString;
open OUT, ">$FILE" or die "Can not open $FILE for writing :$!";
print OUT $contents;
...
I tried to add a new string (named $newString) with a new line at the end of that string to a string variable ($contents). Then when I tried to write that $contents into an output file. I found the output file actually contains hello\n instead of a 'hello' and a new line. Anybody could help me out how to write a string with a new line to a file?
Thanks.
Mike