in reply to Need help constructing a one-liner
I like to start out with something like:perl -F, -lape'join(",",@F[0..3],$F[3],$F[4],@F[4..$#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, -MData::Dumper -lape'Dumper \@F' data.txt
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 | |
|
Re: Re: Need help constructing a one-liner
by nr0mx (Scribe) on Dec 02, 2003 at 14:17 UTC |