... my %installed; # these will be HoA my %hotfix; # where the hash keys are my %ready; # taken from @valid_os my $ninstalled = 0; foreach my $os (@valid_os) { my $path_os = $PATCHPATH . $os; opendir( DIR, $path_os ) or die "dir $path_os not found: $!"; while (my $_ = readdir(DIR)) { next if ( /^\.\.?$/ ); push( @{$installed{$os}}, $_ ); ### SEE NOTE BELOW $ninstalled++; } closedir DIR; } die "No hotfix files are installed in $PATCH_PATH\n" unless ($ninstalled); ... while ($db->FetchRow) { my %hotfix_record = $db->DataHash("os","swname"); push( @{$hotfix{$os}}, $hotfix_record{swname} ); } ... for my $os (@valid_os) { @{$ready{$os}} = Check_Array( @{$installed{$os}}, @{$hotfix{$os}} ); for my $hotfix ( @{$ready{$os}} ) { Add_Hotfix( $hotfix, $os ); } }