foreach $key (sort keys %hash_names) { &subroutine($key, $hash_names{$key}); }