If the idea is to insert line-breaks after certain commas, such that the line-breaks end up being about 80 characters apart, something like this would suffice:
perl -ne 'BEGIN{$/=","} $o.=$_; if(length($o)>=80){ print "$o\n";$o=""
+ }
END{print "$o\n"}' < file.no-breaks > file.with-breaks
(The particular use of quotes there assumes a bash or similar Bourne-like shell.)
Then again, when the purpose of a data file is simply to store list, I personally don't see the point of using commas at all. It's much better to use line-breaks as delimiters between list elements, because then you can use lots of handy unix tools to good effect in order to do things like (de)select, count, sort or otherwise process the elements. And going from comma-delimited (with no line-breaks) to line-break delimited is really simple:
perl -pe 'tr/,/\n/' < comma.delimited > newline.delimited
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.