use strict; my %data; foreach my $file (@ARGV) { print "file: $file\n"; open (LOOKUP, "$file") or die $!; while () { chomp; my ($name, $id) = (split m{\t})[3, 4]; $data{$file}{$id} = $name; } close (LOOKUP); } for my $file ( keys %data ) { print "$file: "; for my $role ( keys %{ $data{$file} } ) { print "$role=$data{$file}{$role} "; } print "\n"; }