legLess has asked for the wisdom of the Perl Monks concerning the following question:
Monks ~
I'm trying (for readability's sake) to assign a branch of a nested hash to a new hash variable. I've solved my problem, but maybe I can decrease my Perl purity and solve it a different way next time. Here's a simplified version of the code:
# 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 };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting a branch of a nested hash
by dragonchild (Archbishop) on Jan 27, 2003 at 18:48 UTC | |
by Aragorn (Curate) on Jan 27, 2003 at 22:14 UTC | |
by dragonchild (Archbishop) on Jan 27, 2003 at 22:24 UTC |