Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!hsdndev!wuarchive!uunet!convex!usenet From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.lang.perl Subject: Re: Perl question relating to pattern substitution Message-ID: <1991Jan05.173102.19622@convex.com> Date: 5 Jan 91 17:31:02 GMT References: <1991Jan5.051035.7202@csn.org> <1991Jan05.155212.16460@convex.com> Sender: usenet@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 28 Nntp-Posting-Host: pixel.convex.com To atob and print out a line, this is substantially faster: print pack("C" x ((length)/2), grep( ($_ = hex) || 1, unpack ("A2"x((length)/2), $_))); While these are also interesting: print pack('C',hex($1)) while s/^(..)//; and this: for ($len = (length)/2, $i = 0; $i < $len; $i++) { print pack('C',hex(substr($_,$i*2,2))); } although conceptually I still like the semi-original: s/(..)/pack("C",hex($1))/eg; I begin to think there are nearly unlimited ways to do nearly *anything* in perl. Can anybody find some more, preferably faster? --tom -- Tom Christiansen tchrist@convex.com convex!tchrist "EMACS belongs in : Editor Too Big!" -me