Khatri has asked for the wisdom of the Perl Monks concerning the following question:

I've written cgi script which reads file from the system and print on the web, so far everything is alright; than I'm updating the file by reading textarea(html*) and print in file. using open, print and close command. Problem is that when I write that in to file, it also print ^M character with all endofline character. do you guys know how can I update/write into file without having that ^M character. Thanks monks.

Replies are listed 'Best First'.
Re: unwanted ^M during print in file
by Skeeve (Parson) on Oct 24, 2005 at 05:53 UTC

    Try putting s/\cM//g in front of the print

    The reason for the ^M is that a line end in certain OSs and (AFAIK) in HTTP is coded as CRLF. I used \cM instead of \r to show you how to code Control-Characters into strings.


    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
Re: unwanted ^M during print in file
by planetscape (Chancellor) on Oct 24, 2005 at 07:13 UTC