I am not sure what the problem is. As others pointed out, writing (text) files under Windows means logical newlines are written as two byte sequences: a carriage return and a line feed. Unix uses a single line feed as newline.
But if this was your only problem, it wouldn't prevent you from looping over the file - all what would happen is that your lines end with carriage return/line feed, instead of just a linefeed. Setting $/ appropriately when reading the file, and chomping the lines would fix that.
Furthermore, the code you give to supposedly writes to the file doesn't even print logical newlines - so there can't be a line ending problem because you don't have newlines!
Or is not printing newlines the problem, and the Windows vs Unix just a red herring? If you view the file under Windows, is the file then ok? Can you loop through the file under Windows?
Something else that might happen is that one of the variables you write contains a line-feed - but without the code and the data, that's impossible to judge.
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.