#!/usr/bin/perl use strict; use warnings; open(my $fh1, '<', "$ARGV[0]") or die "Unable to open $ARGV[0]:$!"; my %hash1; for (<$fh1>) { chomp; my ($key,$value) = split /\s+/, $_, 2; $hash1{$key} = $value; } open(my $fh2, '<', "$ARGV[1]") or die "Unable to open $ARGV[1]:$!"; my %hash2; for (<$fh2>) { chomp; my ($key,$value) = split /\s+/, $_, 2; $hash2{$key} = $value; } for my $key (keys %hash1) { next unless exists $hash2{$key}; print "$key $hash1{$key} $hash2{$key}\n"; }