foreach(@keylist){ my $key = shift; sub get_$key { #code of the func} push @funcs,\get_$key; }