#!/usr/bin/perl -w use strict; my $file1 = "file1.txt"; my $file2 = "file2.txt"; my %hash = (); my %ahash = (); open F1, $file1 or die "Can't open $file1 $!"; open F2, $file2 or die "Can't open $file2 $!"; while(){ my $line = $_; chomp($line); $hash{$line} = $line; } while(){ my $line = $_; chomp($line); (my $w1, my $w2) = split(/ +/, $line); $ahash{$w1} = $w2; } # Matching of two Hash for ( keys %hash ) { unless ( exists $ahash{$_} ) { print "$_: not found in second hash\n"; next; } if ( $hash{$_} eq $ahash{$_} ) { print "$_: values are equal\n"; # Do something with the value } else { print "$_: values are not equal\n"; } }