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]