#!/usr/bin/perl -w # To run this script: # inventory.plx startup=./approved ./inv.txt eval "\$$1\$2;" while $ARGV[0] =~ /^(\w+=)(.*)/ && shift; # process any FOO=bar switches $USAGE = "Usage: $0 startup=./approved ./inv.txt\n"; $approved = $unapproved = 0; !$startup and die "\nThe location of the startup control file was not passed\n", "to this perl script upon invocation, exiting!\n$USAGE\n"; $fh="STARTUP"; -f $startup and -r _ and -s _ and open($fh,$startup) or die "\nThe startup control file $startup does not exist or is empty.\n", "Restore $startup and rerun this program.\n$USAGE\n"; while(<$fh>){/^"([^"]+)"/ and $aparray{$1}="";} # Create the hash # You may want to comment the following two lines: # print "Here's the list of approved software\n"; # foreach $key(sort keys %aparray){print "$key\n";} while (<>) { if ($_ !~ /Query Name: Native software/ && $_ !~ /TME_OBJECT_LABEL\tPACKAGE_NAME\tPACKAGE_VERS\tFILE_PATH/) { /^([^\t]+)\t([^\t]+)\t/; if (exists $aparray{$2}) { $approved++; } # print " $2: Matched!" } else { $unapproved++; print "Computer: $1: $2\n"; } } } # Comment the following line if you don't want totals print "\nApproved programs: $approved, Unapproved programs: $unapproved\n";