Jeff  - thanks  I will try it out.

your answer raises another Q.

  what would I type in   perldoc   -    format  to be able to dig for that
info ???








"Jeff 'japhy' Pinyan" <[EMAIL PROTECTED]> on 07/11/2002 05:42:40 PM

Please respond to [EMAIL PROTECTED]

To:    [EMAIL PROTECTED]
cc:    [EMAIL PROTECTED]

Subject:    Re: removing non-printable char

On Jul 11, [EMAIL PROTECTED] said:

>I am trying to create a sub routine to remove non-printable chars  from a
>string, and am stuck on how I should approach this.

Well, you don't need a subroutine -- just a substitution.

If you're using perl 5.6, you can do:

  $string =~ s/[[^:print:]]+//g;

Before perl 5.6, you can do:

  $string =~ s/[^ -~]+//g;

But it's probably faster (in either version) to use tr/// instead of
s///g:

  $string =~ tr/ -~//cd;

--
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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










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

Reply via email to