# main nested hash my %pages = ( add_event_type => { show => { template => "add_evt", first_control => 'event_type_name', data => { event_type_name => { type => 'text', req => 1 }, event_type_description => { type => 'text' }, }, }, }, ); # elsewhere my $page = "add_event_type"; my $action = "show"; # the code in question my %page = %{ $pages{ $page }{ $action }}; # which allows, later my $first_control = $page{ first_control }; # instead of my $first_control_again = $pages{ $page }{ $action }{ first_control };