#!/usr/bin/perl use strict; use warnings; my $patchlist_file = shift @ARGV; my %patchlist; # read patchlist open my $PATCHLIST, '<', $patchlist_file or die "Can't read $patchlist_file: $!"; while (<$PATCHLIST>) { s/^\s+|\s+$//sg; #trim head/tail whitespace incl. newline $patchlist{$_} = 1; } close $PATCHLIST; #now check files against the patchlist foreach my $file (@ARGV) { open my $FILE, '<', $file or do { warn "Unable to read $file: $!"; next; }; local $/ = "\n\n"; #records separated by double-newline while (<$FILE>) { my ($computer, @patches) = split("\n", $_, 2); my %patch = map { $_ => 1 } @patches; my @missing; # see if each patch is there for (keys %patchlist) { push @missing, $_ unless $patch{$_} } # report printf '%s is missing %d patches.', $computer, scalar @missing; print (scalar @missing ? ' They are: '.join(',',@missing) : ''),"\n"; } close $FILE; }