Update:ysth just pointed out that your example data isn't two lines of 6 comma-separated single digits, but rather 2 x 3 comma-separated small floats.

That doesn't change the possibility of using packed array for you data, but it restrict the choices of available package that may be applicable. It could also double the storage requirement if you need the accuracy.

It also make using PDL perhaps the better choice depending on how you are going to manipulate the data. It carries the burden of being a pain to install, stupid notation, weird restrictions, huge learning curve and dog-aweful documentation--but it is both memory efficient and fast.


The most memory efficient method would be to used a tied array of packed integers or shorts. Each line of your file will require a single scalar, and each value 2 or 4 bytes depending upon the range of your values. As your original file is ascii encoded and contains lots of commas, the resultant memory structure might actually require less space that the file does on disk.

There are several packages on cpan for this: Packed::Array if you need the full 32-bit range for your values, or Tie::Array::packedC which appears to handle different size values, or Tie::IntegerArray and others.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re: Array of Hashes vs. Array of Arrays vs Array of Lines vs ... by BrowserUk
in thread Array of Hashes vs. Array of Arrays vs Array of Lines vs ... 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.