With text files you can only get this to work if the new lines are exactly the same length as the old ones. Text files are just strings of text interspaced with new-lines (on UNIX). Say you see a file in an editor that looks like this:
This is a line
This is another line
and so is this
In reality it looks like this (try od -xc if you are in UNIX):
This is a line\nThis is another line\nand so is this\n
Adding a # to the second line, and then rewriting it, would give us this (look carefully):
This is a line\n#This is another line\nnd so is this\n
Adding an extra character makes the line longer, so it overwrites the first character of the next line!
Write the output lines to a different file instead then, assuming it worked,
rename the new file to the same name as the old one.
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.