#!/usr/bin/perl # http://perlmonks.org/?node_id=1133207 use strict; $| = 1; my $file1 = < }; close $one; #use YAML; print Dump \%hash1; open my $two, '<', \$file2 or die "$! opengin file2"; while(<$two>) { my ($key) = split; exists $hash1{$key} and print "$key $hash1{$key}\n"; } close $two;