> From: yanick1@sympatico.ca [mailto:yanick1@sympatico.ca] > Sent: Wednesday, November 15, 2000 16:36 > To: fwp@technofile.org > Subject: Re: [FWP] joining columns in csv files > > On Wed, Nov 15, 2000 at 03:15:12PM -0600, David Henderson wrote: > > On Wed, Nov 15, 2000 at 07:24:00PM +0000, fergal daly wrote: > > > perl -pe '$i=1;s/,/$i++=~m#^4|5|6$#?"":","/ge' > > ^^^^^^^^^^ > > I'm sure you meant: > > > > > perl -pe '$i=1;s/,/$i++=~m#^(4|5|6)$#?"":","/ge' > > > > Otherwise, 43 (/^4/), 157 (/5/), or 26 (/6$/) would also match. The use of # as the interior regex delimiter isn't good because of the $# sequence. perl -pe 's/,/++$i!~m%^[456]$%&&$&/ge' > In this case: > > perl -pe's/,/$&if++$i,!grep$i==$_,4,5,6/eg' > > get a lower golf score and is correct (as far as I know). Yay! :) perl -pe's/,/3<++$i&&$i<7?"":$&/eg' > Joy, > Yanick More joy, -- Larry Rosler Hewlett-Packard Laboratories http://www.hpl.hp.com/personal/Larry_Rosler/ Larry_Rosler@pobox.com ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe