RE: remove control chars

2003-12-04 Thread Tom Kinzer
Hah! I'm unemployed right now, so how about a contract?!? ;) --Tom Kinzer --Perl Gun for Hire-- -Original Message- From: Rob Dixon [mailto:[EMAIL PROTECTED] Sent: Thursday, December 04, 2003 8:56 AM To: [EMAIL PROTECTED] Subject: Re: remove control chars James Kipp wrote: >

Re: remove control chars

2003-12-04 Thread Rob Dixon
James Kipp wrote: > > I have some C code that I need to convert to perl > and I am pressed for time, which is why I am posting this. Erm. Sorry to spoil the party an' all, but the answer is surely to go to your management and say that you need extra time? Many homework questions to the group have

RE: remove control chars

2003-12-04 Thread Bob Showalter
Kipp, James wrote: > Doesn't quite work. Notice I need to keep any newline ( "\n" ) chars. Sorry, I missed that in the original post. Jeff gave you the fix. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: remove control chars

2003-12-03 Thread Kipp, James
THanks. worked fine as well ! > -Original Message- > From: John W. Krahn [mailto:[EMAIL PROTECTED] > Sent: Wednesday, December 03, 2003 4:24 PM > To: [EMAIL PROTECTED] > Subject: Re: remove control chars > > > Including "\t" and "\n"? >

Re: remove control chars

2003-12-03 Thread John W. Krahn
James Kipp wrote: > > Hi Hello, > I have some C code that I need to convert to perl and I am pressed for time, > which is why I am posting this. All the code does is read each character > from either STDIN or a file and replaces any ASCII control characters with a > space. Including "\t" and "

RE: remove control chars

2003-12-03 Thread Kipp, James
> Thanks. For some reason, this is not working like the C code > is ( my desired result) > > C: > echo | cvt > adc def > hij > > Perl: > echo "abc^Hdef\nhij" | perl -pe 'tr/\040-\176\n/ /c' > abc^Hdef > hij > perl -pi.bak -e 'tr/\040-\176\n/ /c' file > That'll change all char

RE: remove control chars

2003-12-03 Thread Kipp, James
> >if ( (ch<=0176) && (ch>=040) || (ch=='\n') ) { > > putc( ch, stdout ); > >} else { > > putc( ' ', stdout ); > >} > > } > > perl -pi.bak -e 'tr/\040-\176\n/ /c' file > Thanks. For some reason, this is not working like the C code is ( my desired result) C: echo | c

Re: remove control chars

2003-12-03 Thread Jeff 'japhy' Pinyan
On Dec 3, Kipp, James said: >Is the perl getc() function the best way to look at one char at a time? The C way is always never the Perl way. > while ( !feof(fin) ) { >ch=getc(fin); > >if ( (ch<=0176) && (ch>=040) || (ch=='\n') ) { > putc( ch, stdout ); >} else { > putc( '

RE: remove control chars

2003-12-03 Thread Kipp, James
> > > > Is the perl getc() function the best way to look at one char at a > > time? > > > > The C code looks like below. I have some ideas but I am not sure of > > the best way to represent these char ranges in perl > > -- > > while ( !feof(fin) ) { > > ch=getc(fin); > > > > if ( (ch<

Re: remove control chars

2003-12-03 Thread Casey West
It was Wednesday, December 03, 2003 when Bob Showalter took the soap box, saying: : The following one-liner will do the trick: : : perl -pe 'BEGIN {$/=\8192} tr/\040-\176/ /c' myfile : : The /c on the tr/// operator complements the search range, so everything : *not* in the range 040 to 176 gets

RE: remove control chars

2003-12-03 Thread Bob Showalter
Kipp, James wrote: > Hi > I have some C code that I need to convert to perl and I am pressed > for time, which is why I am posting this. All the code does is read > each character from either STDIN or a file and replaces any ASCII > control characters with a space. > > Is the perl getc() function

Re: remove control chars

2003-12-03 Thread Casey West
Hi. I'm in the employ of Casey West, a list admin, to assist you with your question. I've taken the liberty to search Google using the Subject line you provided in your email to the list. I hope one of the links below will be of service to you. I know we all do research before posting here, in som