[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

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.

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! :)

Joy,
Yanick

-- 
$_ = 'Oxsgnm0qtkdr0nudq0C`fna`g+0ats0nm0S`snhmd0sgd0B`ldk0hr'
.'0jhmf-';s,(.),!$1?' ':chr(ord($1)+1),eg;print;

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe