You may want to use chomp(). chomp() will remove the trailing newlines in any scalar context value it's given.
Since you are trying to log people in via a CGI script you don't have to worry about carrage returns (\r) they are Mac (\r) and Windows (\r\n) only.
The 'uniform' return characture is the newline (\n). All browsers do at least conform to that .. ;)
Doing a chomp($var) will get rid of that pesky newline ...
Read about $/ to see how you can modify chomp() to 'chomp' off what you want from the end of a line.
We put the 'K' in kwality!