in reply to dos2unix problem

All the incantations in the other sugestions so far, involve post-processing your script's output. I think your question was how to avoid the ^M at the end of each line in the first place.

You can do that setting the file to "binary mode". I suggest you go look for binmode() in a "perldoc perlfunc" if you're using traditional filehandles.

What happens is that "text" files in Win32 need to have its lines terminated in "\r\n", so a translation happens for/against you in the background whenever you write a text file. If you do not need this, simply declare your file to be binary as explained before. This will get rid of the extraneous "\r".

Good luck.