#!/usr/bin/perl use strict; use warnings; my $fileNameA = $ARGV[0]; my $fileNameB = $ARGV[1]; my %outputHash = (); my @line; my $x = 0; open (my $inputA, "<", $fileNameA); while (<$inputA>) { next unless $_ =~ m/\w/; @line = split(" ", $_); push (@{$outputHash{$line[1]}}, $_); } open (my $inputB, "<", $fileNameB); while (<$inputB>) { next unless $_ =~ m/\w/; @line = split(" ", $_); if (exists ${$outputHash{$line[2]}}[0]) { for ($x = 0; $x < @{$outputHash{$line[2]}}; $x += 1) { print STDERR "${$outputHash{$line[2]}}[$x]"; } } }