in reply to Difficulty Mapping Data

[ For reference, the OP is asking a simpler version of a question he asked previously. ]

I am trying to make sure that all host-aliases that exist in file1 also exist in file2.

Put differently, you want to know if there's a host-alias in file1 that doesn't exist in file2. (It's often convenient to convert questions that use "all" into questions that use "each".)

Load up the host-aliases from file2. Store them in a hash keyed by the host-alias for ease of lookup. The value doesn't matter. (I'd use something true like 1.)

Then iterate through the host-alias in file 1. For each host-alias you find in file1, check if it's in file2 (by checking if it's in the hash).

You can stop iterating as soon as you find one that's missing and still satisfy your spec, but you might want to continue iterating to find all the missing host-aliases.

Replies are listed 'Best First'.
Re^2: Difficulty Mapping Data
by walkingthecow (Friar) on Sep 07, 2010 at 20:22 UTC
    My apologies if I am not understanding what you're saying. My question in this thread may not be very well worded.

    I am able to see if all host-aliases that exist in file1 also exist in file2. The problem that I now face is that I need to know if the host-alias exists under the same "host id" in both files.

    So, if host-alias www.foo.com exists under "host id" bobjones in file1, it also must exist under bobjones in file2. I hope that makes sense :)

      I am trying to make sure that all host-aliases that exist in file1 also exist in file2.

      and

      I need to know if the host-alias exists under the same "host id" in both files.

      are very different problems. Unfortunately, I've already spent too much time answering the first question and cannot help you at this time.

      if host-alias www.foo.com exists under "host id" bobjones in file1, it also must exist under bobjones in file2.

      Is the following also true?

      if host-alias www.foo.com exists under "host id" bobjones in file2, it also must exist under bobjones in file1.