for my $primary (sort keys %CODEREFS) { for my $secondary (sort keys %{ $CODEREFS{$primary}}) { my $code = $CODEREFS{$primary}->{$secondary}->{cref}; no strict 'refs'; *{"mymodule_${primary}_${secondary}"} = $code; }; };