Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!chalmers.se!appli!niklas From: niklas@appli.se (Niklas Hallqvist) Newsgroups: comp.lang.perl Subject: Re: Need detab function Keywords: detab Message-ID: <1208@appli.se> Date: 21 Nov 90 02:29:25 GMT References: <1990Nov19.210123.20558@gtisqr.uucp> Organization: Applitron Datasystem AB, GOTHENBURG, SWEDEN Lines: 31 stu@gtisqr.uucp (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? :-) Well, Here's my try: perl -pe 's/^([^\t]*)\t/$1." "x(8-length($1)%8)/e while /\t/;' Now, this is a bad one, since I loop once for each tab on a line. I thought this one would take care of that problem, but NO, it did NOT! perl -pe 's/^([^\t]*)\t/$1." "x(8-length($1)%8)/eg;' Shouldn't the g flag work with the e flag, doing just what I did explicitly in my first try? Now, don't worry... I'm sure Randal & Larry will replace this script with a thirty-byter... ;^) Niklas -- Niklas Hallqvist Phone: +46-(0)31-40 75 00 Applitron Datasystem Fax: +46-(0)31-83 39 50 Molndalsvagen 95 Email: niklas@appli.se S-412 63 GOTEBORG, Sweden mcsun!sunic!chalmers!appli!niklas