my %first_hash = processfile($file2, $list2); foreach my $k (sort keys %first_hash){ print "$k\n$first_hash{$k}\n"; }