Path: utzoo!attcan!uunet!ogicse!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.lang.perl Subject: Re: unctrl Message-ID: <1990Oct16.174056.11760@iwarp.intel.com> Date: 16 Oct 90 17:40:56 GMT References: Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 28 In-Reply-To: fuchs@it.uka.de (Harald Fuchs) In article , fuchs@it (Harald Fuchs) writes: | How about a one-liner, Randal? My "one-liner" for non-metachars is already in the distribution (dumpvars.pl): sub unctrl { local($_) = @_; s/([\001-\037\177])/'^'.pack('c',ord($1)^64)/eg; $_; } To add meta to that, do something like: sub unctrl { local($_) = @_; s/([\200-377])/'M-'.pack('c',ord($1)^128)/eg; s/([\001-\037\177])/'^'.pack('c',ord($1)^64)/eg; $_; } Untested, but you get the idea, I hope. print &unctrl("Just another Perl hacker,"); -- /=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!"=/