Let's suppose you read your "file two" first, like this:
open( P, "<", "Two.txt" ) or die "Two.txt: $!"; my @patches = sort <P>; chomp @patches; close P; my %patch_id; my $seq_num = 0; $patch_id{$_} = $seq_num++ for ( @patches );
That assigns a numeric ID (from 0 to N-1) to each of the N patch names listed in that file, in sorted order. Now read "file one" like this:
my %comp_patch; # will be a hash of arrays my $comp_name; # will store most recently seen computer name open( C, "<", "One.log" ) or die "One.log: $!"; while (<C>) { chomp; if ( /^KB\d+/ ) { # this is a patch name if ( not exists( $patch_id{$_} )) { warn "Computer $comp_name has unknown patch: $_\n"; next; # (might want to do something else here) } $comp_patch{$comp_name}[$patch_id{$_}] = $_; } elsif ( /^\S+/ ) { # not a patch name, must be a computer name $comp_name = $_; } }
For each computer, you now have an array of patches, with array elements 0 through N-1. But if a given computer did not have a particular patch, the corresponding array index in the HoA structure will be undef. So that is what you check for, to see which patches are missing from each computer:
for my $cname ( sort keys %comp_patch ) { for my $pnum ( 0 .. $#patches ) { print "$cname lacks $patches[$pnum]\n" unless ( defined( $comp_patch{$cname}[$pnum] )); } }
(untested)

In reply to Re: Finding out what computer does NOT have certain data by graff
in thread Finding out what computer does NOT have certain data by Sunnmann

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.