if its a unix file,.open in vi :%s/ctrl+v ctrl+m//g (where ctrl+v and ctrl+m gives the ^M character.)
cheers On Fri, 19 Dec 2003, Douglas Lentz wrote: > David Inglis wrote: > > >I am reading in a csv file and it has a control character ^M at the end > >of each line how can I remove these charaters, I have tried the following > >and had no success. > > > >$a=~s/\^M//; > >$a=~s/^M//; > > > > > >Any help appreciated thanks. > > > > > > > > > This is an MS-DOSsy file, where each line is terminated by the famous > CR/LF combination. "^M" is the carriage return. Between the regex > slashes ("the jungle") "^" means "beginning of line", so what you have > instructed regex to do is erase any capital "M" that happens to occur at > the beginning of a line. > > If you have a copy of the program dos2unix around, it will take care of > this for you, otherwise you can try $a =~ s/\x0D//; > > which means replace any CR you find with null. HTH. > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>