If your trying to do this on a unix based system 

^M is equivalent to \r\n so you can get rid of \r I believe. 

-----Original Message-----
From: Remy Guo [mailto:[EMAIL PROTECTED] 
Sent: 21 May 2008 15:20
To: Rob Coops
Cc: Perl Beginners
Subject: Re: what is ^M at the end of a line?

it's really interesting... then how can i match that ^M using regex?
i've tried "chomp" when reading each line but it doesn't work...

2008/5/21 Rob Coops <[EMAIL PROTECTED]>:

> That ^M is a line feed, or well the windows version of a line feed.
>
> There are several different ways in which to write a line feed and of 
> course to make our lives better *nix, Dos/Windows and Mac all have 
> their own way of writting them.
>
> So Jeff's suggestion relies on a little application that simply finds 
> ad relapces all the dos/windows ways of doing things like line feeds 
> and replaces them with the unix version of the same.
>
> If you feel like doing this in perl a simple regex will do the trick, 
> at least for the line feeds, but there is more windows fun to be had, 
> like the way MS Word replaces ceretain characters like " ' - and even 
> ... with a special charatcer because they are estetacly more pleasing 
> to the reader of the document. I am sure there are more examples and 
> dos2unix covers them all.
>
> So if it is a single file and only a one of then dos2unix is the 
> easiest way, if you want to do it in perl then you will most likely 
> have to use a regex because not all moachines will have the dos2unix 
> applicaiton available.
>
> Regards,
>
> Rob Coops
>
>   On Wed, May 21, 2008 at 10:45 AM, Remy Guo <[EMAIL PROTECTED]>
> wrote:
>
>> hi all,
>> i have a text processing script that can work with a file but cannot 
>> work with another file that has the same content.
>> as i compared the 2 files, i found the file that cannot work has a 
>> "^M" at the end of each line. what is this? is this what made it not
work?
>> by the way, i'm under unix.
>> thanks....
>>
>> -Remy
>>
>
>


This e-mail is from the PA Group.  For more information, see
www.thepagroup.com.

This e-mail may contain confidential information.  Only the addressee is
permitted to read, copy, distribute or otherwise use this email or any
attachments.  If you have received it in error, please contact the sender
immediately.  Any opinion expressed in this e-mail is personal to the sender
and may not reflect the opinion of the PA Group.

Any e-mail reply to this address may be subject to interception or
monitoring for operational reasons or for lawful business practices.





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to