in reply to Finding out what computer does NOT have certain data
I hope that makes sense. Here is some code to demonstrate:
Which prints:#!/usr/bin/perl -w use strict; my %computers; my $computer; my @required_patches = qw( KB893756 KB893803 KB896422 KB896423 KB899588 KB899591 KB911927 KB921883 ); while (my $line = <DATA>) { chomp($line); if ($line =~ /^KB\d{6}/) { $computers{$computer}{$line}++; } else { $computer = $line; } } for my $patch (@required_patches) { for my $computer (keys %computers) { if (!exists $computers{$computer}{$patch}) { print "$computer is missing patch $patch\n"; } } } __DATA__ Computer1 KB893756 KB896422 KB896423 KB899588 KB899591 KB921883 Computer2 KB893756 KB896422 KB896423 KB899591 KB917159 KB921883 Computer3 KB893756 KB896422 KB899588 KB899591 KB917159 KB921883
Computer3 is missing patch KB893803 Computer2 is missing patch KB893803 Computer1 is missing patch KB893803 Computer3 is missing patch KB896423 Computer2 is missing patch KB899588 Computer3 is missing patch KB911927 Computer2 is missing patch KB911927 Computer1 is missing patch KB911927
Cheers,
Darren :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Finding out what computer does NOT have certain data
by Sunnmann (Acolyte) on Sep 01, 2006 at 16:38 UTC | |
by Sunnmann (Acolyte) on Sep 01, 2006 at 16:53 UTC |