I have a question regarding how newlines are added at the end of each line record of an array when you use Tie::File for a local file. After modification, while when curling or opening the file in an advance text editor like wrangler, I see the newline after record insert without an issue. But on a no-format text editor like Notepad, I don't see the newline and two lines are combined. Any idea why this is the case? I specify the newline in the new record so I'm not sure why its not picking it up....
This is as basic as the code gets. Use Tie::File on a file, on a particular line insert something, and at the end use \n (which should be unnecessary anyway). But it would seem that line 3 and line 4 become combined on a no-format text editor like notepad, but appears correct on curl or an advance text editor. Any idea why?
#$file contents below....
#Line1 - Blah
#Line2 - Blah
#Line3 - Blah
#Line4 - Blah
#Line5 - Blah
tie @file_lines, 'Tie::File', $file or die;
$file_lines[3] = "This is my new record on line 3,\n";
untie @file_lines or die "$!";
#$file contents now has (on no format text editors)...
#Line1 - Blah
#Line2 - Blah
#Line3 - This is my new record on line3,Blah
#Line4 - Blah
#Line5 -
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.