foreach my $sub_ref (keys %test_procs){ foreach(@procs){ print "$test_procs{$sub_ref}\n" if $sub_ref eq $_; } } #### foreach(@procs){ print "$test_procs{$_}\n" if $test_procs{$_}; #If it's defined. }