in reply to Multiple File handling and merging records from 2 files

Yes, that's definitely one way to populate a nested hash. Here's a full-blown example that includes reading the files. I've written the example much more verbosely than I would normally in hopes it makes it more clear. This does not go on with sorting and lookups, just purely how to populate a hash from the files.

use warnings; use strict; use Data::Dumper; my %app_map; open my $fh1, '<', 'app.txt' or die $!; while (my $line = <$fh1>){ my ($app, $mem, $lang) = split /\s+/, $line; $app_map{$app}{mem} = $mem; $app_map{$app}{lang} = $lang; } close $fh1 or die $!; open my $fh2, '<', 'app2.txt' or die $!; while (my $line = <$fh2>){ my ($app, $cpu, $cores) = split /\s+/, $line; $app_map{$app}{cpu} = $cpu; $app_map{$app}{cores} = $cores; } close $fh2 or die $!; print Dumper \%app_map;

...and given the two files look like this (app.txt):

App1 4 Perl App2 8 Java App3 8 Java App4 4 PHP App5 8 C#

...and app2.txt:

App1 1.5 2 App2 2.5 4 App3 2.8 4 App4 2.8 2 App5 2.8 2

Output:

$VAR1 = { 'App5' => { 'lang' => 'C#', 'cores' => '2', 'cpu' => '2.8', 'mem' => '8' }, 'App1' => { 'cores' => '2', 'cpu' => '1.5', 'mem' => '4', 'lang' => 'Perl' }, 'App4' => { 'cpu' => '2.8', 'cores' => '2', 'mem' => '4', 'lang' => 'PHP' }, 'App3' => { 'cpu' => '2.8', 'cores' => '4', 'mem' => '8', 'lang' => 'Java' }, 'App2' => { 'mem' => '8', 'cores' => '4', 'cpu' => '2.5', 'lang' => 'Java' } };