Problem with Perl script after moving from a Windows/Apache Server to a UNIX server.

I have a Perl script that worked fine before moving it to justhost.com. It was on a Windows/Apache server. Just host is using UNIX. Other Perl scripts on other sites that were also moved work fine so I know Perl is functioning.
The script is called cwrmail.pl and is located in my cgi-bin.
When I run the script I get a 500 error. The script is called from a CGI Post form on another page. I have narrowed it down to the "read" statement...as follows:

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-FA-F0-9][a-FA-F0-9])/pack("C", hex($1))/eg;
$contents{$name} = $value;
}

If I comment out this section and add a "print" function, it works and prints to the screen so I am positive this section is the problem. The "read" statement is correct. The chmod is 755 for both the script and the cgi-bin.I have tried uploading via FTP in both ASCII and binary to no avail. I have edited in both NotePad ++ and WordPad.
The support at justhost is pretty good except they seem to be lacking Perl techs. I don't think this is a Perl issue but really not sure!
Anyone have any other ideas??
Thanks,
Bob

Try editing it in a UNIX text editor instead of a Windows one. Windows ones will fill the file with useless carriage returns which UNIX languages will consider parts of the statements themselves.

Thought Notepad++ wasn't a Windows text editor. Will try another.
Thanks

If it runs inside Windows, it's a Windows text editor.

I'm suggesting you log into the server and handle the file there.

Thanks...will let you know.

Didn't work. I used the code editor on the unix server. Thanks for trying to help me though.

what error do you see in the apache logs ?

UNIX log? No error messages!

Notepad++ can convert EOL characters to *nix format via Edit menu > EOL Conversion

There is also a dos2unix command in Linux to convert the EOLs in a file.

Apache logs may be in /var/log/apache2

Thanks for the info. Will check it out.