Normally to read a textfile in this fashion should be just fine. However my hinch is that the code example that you presented is incomplete:
while (my $lines = <FIN>) { chomp $sword;
e.g. I would have expected a chomp $lines within the loop. Maybe show us some more code details?

Now if you accidently would parse a file that is not a textfile the inputline may end up being too long and on some systems you could run out of memory.

One cause for the above could be platform differences i.e. if you read on an Windows platform a file originally created on a Unix platform the textline separator might be different and your program may fail to recognise end-of-line.
Note that this problem would not be as bad if the source is Windows and the destination is Unix. In that case you just find an extra "\r" as the last character on the line after you have chomped the input.


In reply to Re: Out of memory error while Reading 5GB text file by varian
in thread Out of memory error while Reading 5GB text file by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.