how do you define a line? if it's as simple as 'a dot marks
the end of a line' then you would
- read in the file at once (1)
- substitute dots with a dot and a newline
- print string to newly opened file (2)
(1) might be more efficient to set $/ to '.' if the file is large, and then read into an array line by line
(2) use file locking and don't close the file in between,
if that's necessary, e.g. if more than one process might open the file
if you're having problems with one of the steps you're
welcome to add specific questions.
something to read: perlopentut, perlre, flock
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.