I know I'm not really answering your question (but that's because I suspect an XY Problem here), but I'd likely approach the same issue completely backwards. Instead of loading anything into memory, I'd likely start by trying to transform your CSV file into a CSV file that has all the information of interest in it. And then I'd use DBD::CSV (again, since I probably would have used it both to read the original CSV file and write the transformed CSV file) to create SQL JOIN queries to get the information I want out of each.

The advantage to this is that I could then migrate to another database (which is where data should be), such as mySQL, PostgreSQL, SQLite, or even DB2 or Oracle or whatever, when I need more speed. I suspect that this would be faster than whatever you do in perl... even if, at the beginning of each run, I need to pre-populate the database by loading from the CSV files. Even before migrating to a database, I don't expect this to be hugely slower than your approach, but it does scale better.


In reply to Re: Loading file into memory by Tanktalus
in thread Loading file into memory by walkingthecow

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.