Problem writing to a file

When I write to a text file, it puts this character
 in place of a new line. Here is the script I'm using

$comments = $formdata{$key};

open(LOG,">>../clientaccess/password.txt")
  || &ErrorMessage;
foreach $key (sort keys(%formdata)) {
      print LOG "$formdata{$key}\n";
}
close(LOG);

Can someone help me get rid of it?
kch011099Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

monasCommented:
you might try to change \n to \r\n if you would like ms-dos style line-ends...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
olthoffCommented:
What character is it putting in?
0
kch011099Author Commented:
It is putting in a box-like character in place of a new line.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

olthoffCommented:
I can't explain why it is adding the character, but you should be able to determine what character it is by:
print(ord(substr($line, startingpos,1)));

You can then strip that character from the file, or the line that you are writing.  
$formdata{$key} =~ s/\015//;

This removes the character (Octal value)
0
Gaetano010400Commented:
This is kind a strange... What priviliges has been granted for execution of the script ? Most common is chmod 755.... I do not think this is going to help you out, just checking for at stupid error (Been there, done that) :)

/Gaetano
0
kch011099Author Commented:
I have all three boxes checked under execute, read, and write.

This is actually really strange because I am using this exact same script for another site and it works flawlessly.
0
KennyIT Application ExecutiveCommented:
As monas said, but in reverse, is you  use \r\n in NT, you will get that "illegal" character. Try switching between the 2 (\n and \r\n). I am very sure this is the problem cause I have had it before.
0
kch011099Author Commented:
Thank you everyone. The \r did the trick. It was the \n that was creating the box character, so I just got rid of it and used only \r.  
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.