jcoxen has asked for the wisdom of the Perl Monks concerning the following question:
I have a nagging little (and probably ego-shatteringly easy) problem that I can't figure out or search out the answer to. I have several files that I have to convert from 80 column data dumps to csv format by replacing the spaces at certain columns with commas and then deleting the remaining spaces. If I were using sed, I'd use a statement like
to put a comma at column 11 of every line - repeating for columns 25, 31,35, etc. My problem is that Perl won't accept that syntax and I can't find or figure out the comparable Perl syntax. Ideally, I'd be able to put all the replacements on one line with something like this:sed -e "s/./,/11"
I could load the row into an array and tackle the problem that way but I feel that I should be able to do it via regex a lot easier. Can anyone tell me what I'm missing?s/./,/{11,25,31,35,39,44,49,66,71,76.78};
Thanks,
Jack
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Positional regex statements
by Eimi Metamorphoumai (Deacon) on Oct 04, 2004 at 18:15 UTC | |
by jcoxen (Deacon) on Oct 04, 2004 at 18:54 UTC | |
|
Re: Positional regex statements
by Zaxo (Archbishop) on Oct 05, 2004 at 05:17 UTC | |
by jcoxen (Deacon) on Oct 05, 2004 at 14:05 UTC |