> > 
> > 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<=0176) && (ch>=040) || (ch=='\n') ) {
> >       putc( ch, stdout );
> >     } else {
> >       putc( ' ', stdout );
> >     }
> > 
> >   }
> 
> 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 changed to a space.
> 
> The BEGIN block sets $/ so that input gets processed in 8kb chunks,
> regardless of the format of the input files. (Can that be done with a
> command-line option to perl?)

Thanks

Doesn't quite work. Notice I need to keep any newline ( "\n" ) chars. 
Here is an example:

echo "abc^Hdef\naa" | perl -pe 'BEGIN {$/=\8192} tr/\040-\176/ /c'

returns: abc^Hdef aa




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to