mdb@ESD.3Com.COM (Mark D. Baushke) (05/25/90)
I want the perl equivalent of: tr -d '[\001-\011\013-\037\177]' without starting a tr process. I tried: $\ = "\n"; while (<>) {chop; tr/\001-\011\013-\037\177//; print;} with no luck. It is like the tr is not present. I know that I can use something like: $\ = "\n"; while (<>) {chop;tr/\001-\011\013-\037\177/ /; print;} to change all control characters to a space, but that is not what I need. Thanks in advance, -- Mark D. Baushke Internet: mdb@ESD.3Com.COM UUCP: {3comvax,auspex,sun}!bridge2!mdb
merlyn@iwarp.intel.com (Randal Schwartz) (05/25/90)
In article <MDB.90May24191812@kosciusko.ESD.3Com.COM>, mdb@ESD (Mark D. Baushke) writes: | I want the perl equivalent of: tr -d '[\001-\011\013-\037\177]' | without starting a tr process. I tried: | | $\ = "\n"; while (<>) {chop; tr/\001-\011\013-\037\177//; print;} | | with no luck. It is like the tr is not present. I know that I can use | something like: | | $\ = "\n"; while (<>) {chop;tr/\001-\011\013-\037\177/ /; print;} | | to change all control characters to a space, but that is not what I need. | | Thanks in advance, tr doesn't do "tr -d". (We were just recently talking about this in c.l.p.) What you want is: while (<>) { s/[\001-\011\013-\037\177]//g; print; } Maybe you want "\177-\377" instead of "\177" in that last line. And starting with "\000" instead of "\001". Which then makes it equivalent to: while (<>) { s/[^\n\040-\176]//g; print; } using a negated character class. Yeah, yeah, that's the ticket. :-) $_=pack("c25",65..90);y/A-Y/Just another Perl hacker,/;print -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/