The problem is its unclear, its always better to be clear in code. It will
also remove any formatting from the end of lines. If you wanted to be just
as crude you can use chomp. 

-----Original Message-----
From: Rob Dixon [mailto:[EMAIL PROTECTED] 
Sent: 03 September 2007 13:37
To: beginners@perl.org
Cc: Andrew Curry
Subject: Re: how to remove ^M character from every line

Andrew Curry wrote:
>
> From: Beginner [mailto:[EMAIL PROTECTED]
>> 
>> On 3 Sep 2007 at 17:26, divya wrote:
>>>  
>>> A file generated on Windows machine is used on linux m/c while
scripting.
>>> A sample line from the file is as shown:
>>>
>>> //-------------------------------------------------------^M
>>> File name : project_name^M
>>> .....
>>>
>>> Now in the perl script how can I remove ^M without running the 
>>> command dos2unix.
>>>
>>> Note: Trying to split the line whenever ^ detected is not working.
>>>
>>> Looking forward for your response.
>> 
>> I use s/\s+$//;
>
> That will just remove all space (\s+$) at the end of the file. \r \n 
> are different

No they're not. /\s/ matches HT, LF, FF, CR and space. Dermot's is a very
good way of trimming all combinations of CR and LF, as long as you're not
interested in trailing whitespace characters.

Rob


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