in reply to Finding out what computer does NOT have certain data

This is what I would do:

I hope that makes sense. Here is some code to demonstrate:

#!/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
Which prints:
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
    So I get my Computer information from a script I have created that gets the information and parses through another file to get the list I gave you guys (of course it is only a snipet of my list because I thought putting 150+ computers worth of data was a bit much).

    In your code, you have the line, while (my $line = <DATA>) {

    The <DATA> would that be me openining the file using a statement beforehand that looks as such?

    open (DATA, "One.txt") or die "One.txt: $!"; while (my $line = <DATA>) { chomp($line); if ($line =~ /^KB\d{6}/) { $computers{$computer}{$line}++; } else { $computer = $line; } }
      I have it and it works now. The end rsult is an excel sheet that outputs the information in alphabetical order. SWEET!

      Though I still want to learn more so I am trying the rest of the suggestions here. Have to see what i can and cannot understand.