in reply to Need help constructing a one-liner

How about using autosplit mode?
perl -F, -lape'join(",",@F[0..3],$F[3],$F[4],@F[4..$#F])' data.txt
I like to start out with something like:
perl -F, -MData::Dumper -lape'Dumper \@F' data.txt
To make sure that i am populating @F correctly first, then move on. Once you feel comfortable, you can add inplace editting:
perl -F, -lapi.bak -e'$_=join(",",@F[0..3],$F[3],$F[4],@F[4..$#F])' da +ta.txt

UPDATE:
replaced -lane with -lape and dropped print ... silly /me ;)

UPDATE2:
fixed error pointed out by nr0mx and duff ... thanks guys :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: Re: Need help constructing a one-liner
by duff (Parson) on Dec 02, 2003 at 14:54 UTC

    You know, you can do this too:

    perl -F, -lapi.bak -e'$_=join(",",@F[0..3,3,4,4..$#F])' data.txt

    Not that we're golfing or anything :-)

    Oh, and you forgot your assignment to $_. Otherwise it won't print what you want

Re: Re: Need help constructing a one-liner
by nr0mx (Scribe) on Dec 02, 2003 at 14:17 UTC
    Thanks, that worked splendidly!
    I had to reassign the join back to $_, but ths is exactly what I had been looking for.