PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: ivan at algorithmics dot com (Ivan Simon)
Subject: Re: Control Characters in a Pattern
Date: Feb 22 1996 6:41PM

On Feb 22, 10:10am, Subbarao Chitturi wrote:
> Subject: Control Characters in a Pattern
> How can I remove control characters in a string?
>
> I created a data file on my PC and ftpd the file to the UNIX system so
> that I can BCP into Sybase. When I use vi, the last character showns up as ^M.
> I want to delete this. It is a redundant character. I am writing a script
> to delete such control characters, not only at the end of the line but
anywhere
> in the file. I know chop function only deletes at the end of the line but what
> about finding the control characters set in the middle of the line?
>
> Thank you in advance.
>
> Subbarao.
> chitturi@dns1.state.mi.us
> ============================================================================
> =====
> Disclaimer = I question and speak for myself.
>
>-- End of excerpt from Subbarao Chitturi

Try a variation on the following. It removes any trailing commas (,) and the
trailing ^M. \cM matches the ^M. The $ ties the string to the end of the
line so if you are looking for control characters in the middle of a line
you won't want it.

  $inputRec =~ s/,*\cM*$//g;

The following will remove ^M from anywhere in the line.

  $inputRec =~ s/\cM//g;

-- 
----------------------------------------------------------------------
Ivan Simon.
Algorithmics Incorporated, 822 Richmond St. W., 3rd Floor.
Toronto, Ontario, Canada, M6J 1C9.
TEL: (416)703-0898 ext. 242, FAX: (416)703-0767, ivan@algorithmics.com
----------------------------------------------------------------------