I have a file of large records. Each record spans multiple lines:
id:999999 Name:John Doe StreetAddr1:44 Someplace Dr City:Someplace State:CA Zip:99999 MxId:33 Routing:b7 ---------- id:789654 Name:Someone Else StreetAddr1:33 Someotherplace Dr etc...
Each record has more fieldname fieldvalue pairs, for the purpose of this example I removed them.

My task is to keep the file format the same but sort the records by Zip. I must admit I'm at a loss as to how to begin. As each record is rather large and the size of the entire file could also be rather large I'm thinking I don't want to slurp the whole file into an array or a hash and then somehow sort that. Any pointers (and I'm not asking you to do the work for me and I'm not asking for code), be they links to modules or a simple explanation of how I would begin would be most helpful.


In reply to Sorting A File Of Large Records 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.