As with others, I'm going to have to ask 'why'. We need the 'why' to give you a good solution.

If we take the premise that you 'just need to', then the solution is to get a machine with 10G of memory on it and then you won't get that error. The error of running out of system memory isn't perl specific. You'd get that error in C or any other language. You've hit a physical limit.

If it turns out that you really don't NEED to have it all slammed into memory at once and passed around, you have other options as people have pointed out. Passing file handles is a good solution. Another good solution is to use Sys::Mmap; to memory map your file. You can also use PerlIO with the :mmap tag. At any rate, give us some more info and we can provide a solution to the problem, even if it's one you wont' like. :)

--
I used to drive a Heisenbergmobile, but every time I looked at the speedometer, I got lost.

In reply to Re: Reading huge file content by KurtSchwind
in thread Reading huge file content by siva kumar

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.