Removing ^M characters from text documents
Posted on 2002-06-19
I'm a semi-newbie, but I have been working with perl for about a year now. So bear with me.
I'm writing a script to take html files written in windows and remove the tags. I've got everything under control except that I can't seem to get rid of some pesky ^M characters. They're causing the text to lose the format I'm giving it, so they need to be removed. I've tried to use some regular expressions:
$text =~ s/^M//g; # Attempt 1
$text =~ s/\^M//g; # Attempt 2
$text =~ /.(.*)/g; # Attempt 3 (the ^M seems to be at the start of each line)
$finished_text = $1;
Well, I've been trying things for a few days now, and am getting nowhere, so if someone could tell me what I'm doing wrong, it would be much appreciated.