#/usr/bin/perl use strict; use warnings; @ARGV == 2 or die "Must specify 2 files!\n"; my $afile = shift; my $bfile = shift; my $ahash = make_hash($afile); my $bhash = make_hash($bfile); sub make_hash { my $file = shift; my %hash = (); open IN, "<$file" or die "Can't open '$file': $!\n"; while () { chomp; my ($key,$val) = split(/,/,$_); $hash{$key} = $val; } return \%hash; } print "In A hash but not B hash:\n", map {"$_\n"} grep {not exists $bhash->{$_}} keys %$ahash; print "In B hash but not A hash:\n", map {"$_\n"} grep {not exists $ahash->{$_}} keys %$bhash; print "In A hash and B hash but different:\n", map {"$_\n"} grep {exists $bhash->{$_} and $ahash->{$_} ne $bhash->{$_}} keys %$ahash;