#!/usr/bin/perl # ## Define variables # $EMPTY=""; # ## Open file 1 for input and place contents into hash table # $FILENAME1 = shift; open(FILE1,"./$FILENAME1") || die "USEAGE ./checker file1 file2\n"; while(){ @PACKAGE1 = split(',',$_,2); #$FILE1PKG{$PACKAGE1[0]}{$PACKAGE1[1]} = $_; $FILE1PKG{$PACKAGE1[0]}=$PACKAGE1[1]; } close FILE1; # ## Open file 2 and compare the two this will create several outputs # $FILENAME2 = shift; open(FILE2,"./$FILENAME2") || die "USEAGE ./checker file1 file2\n"; while(){ @PACKAGE2 = split(',',$_,2); $FILE2PKG{$PACKAGE2[0]}=$PACKAGE2[1]; } close FILE2; # ## Read in hash and do comparisons # for $MASTERPKG ( keys %FILE1PKG ){ print "FILE1 PACKAGE: $MASTERPKG VERSION: ",$FILE1PKG{$MASTERPKG}; print "FILE2 PACKAGE: $MASTERPKG VERSION: ",$FILE2PKG{$MASTERPKG}; $VERSION1 = $FILE1PKG{$MASTERPKG}; $VERSION2 = $FILE2PKG{$MASTERPKG}; #print "\nVERSION1: $VERSION1 VERSION2: $VERSION2\n"; if ($VERSION1 eq $VERSION2) {print "SAME\n"}; if ($VERSION2 eq $EMPTY) {print "MISSING PACKAGE\n"}; if (($VERSION1 ne $VERSION2) && ($VERSION2 ne $EMPTY)) {print "DIFFERENT\n"}; }