Greetings all,

I'm still a relative Perl newbie, and most of my experience/past projects have been simple parsers. Right now, I have a file listing contained in a file in the following format:

Date (MM-DD-YYYY) \t Time (HH:MM PM) \t Size (in bytes, no formatting) \t Full file path (Directory\filename)

So a sample record would be like:

12-25-2005     12:30 PM     350234     C:\someplace\somefile.txt

What I want to do is sort the list by size, preferably in descending order. I've tried the sort function, and a ST sort, but I get an error on my system that I've run out of memory. This may be because the file I'm using is approximately 400 MB, and I only have 1 GB of memory available.

Any help will be most appreciated. Thank you!

For reference, this is what was used for the last attempt:

@in = <INPUTFILE>; @out = map $_->[0] => sort { $a->[1] <=> $b->[1] } map [$_, (split(/\t/))[2]] => @in;

In reply to Sorting a (very) large file by condar

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.