Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!emory!ogicse!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.lang.perl Subject: Re: Need detab function Keywords: detab Message-ID: <1990Nov20.175000.1407@iwarp.intel.com> Date: 20 Nov 90 17:50:00 GMT References: <1990Nov19.210123.20558@gtisqr.uucp> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 26 In-Reply-To: stu@gtisqr.uucp (Stu Donaldson) In article <1990Nov19.210123.20558@gtisqr.uucp>, stu@gtisqr (Stu Donaldson) writes: | I need a detab function written in perl. I'm sure there must be | something other than the brute force method of implimenting this. | | Any help would be appreciated... | | How about a one liner? :-) Like maybe: perl -pe '1 while s/\t/" " x (8-length($`)%8)/e' This is not the same as: perl -pe 's/\t/" " x (8-length($`)%8)/eg' # wrong! Although I didn't test it, I recall something about length($`) being wrong in a global edit, so I skipped that version. The first one works, however. print "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: "Intel: putting the 'backward' in 'backward compatible'..."====/