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 () { 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 = $_; } }