Hello all, I have two files, one is a list of computer names and IP addresses:
10.1.3.1:frank 10.1.3.2:john 10.1.3.3:mis23455 ...
And the other file looks like this (DJB data file):
... +host-1-3-1-10:10.1.3.1 +host-2-3-1-10:10.1.3.2 +host-3-3-1-10:10.1.3.3 ...
I want to take the first file, loaded with ip:machinename, and search the second file based on the IP address. Then, I want to replace the +host-* part with the proper machine name for that IP address. The finished data file (file 2) would look like this:
... +frank:10.1.3.1 +john:10.1.3.2 +mis23455:10.1.3.3 ...
In other words, I want to use the data in the first file to search and replace data in the second. The data file is 130000+ lines long. What would be the best way process such a large file? I'm quite stuck at this point so any help would be useful.
Thanks.

In reply to Search and replace on a 130000+ line file. by brendonc

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.