in reply to Comparing two columns

This snipplet just prints common keys in the two files file1.txt and file2.txt:

se strict; use warnings; sub get_file { open my $FILE, '<', shift or die $!; return map {chop; $_ => $_} <$FILE>; } my %a = get_file 'file1.txt'; my %b = get_file 'file2.txt'; { no warnings 'uninitialized'; print "$_\n" for grep {$_} @a{keys %b}; }

The above can easilly be done using sort, uniq and grep.