I like the idea of your extended each to iterate through deeply nested structures. It especially simplifies printing data, or makign minor alterations.
More generally, though, my approach is to isolate each layer. Ideally, each level should be an array of objects or a hash of objects, which in turn is an array or hash of objects. Especially so if you have a number of operations carried out on the objects.If there are only one or two operations on the structures, I use a function for each layer:
sub process_frumptions { my ( $frumption_set ) = @_; for my $frumption ( keys %$frumption_set ) { process_one_frumption $frumption; } } sub process_one_frumption { my ( $frumption ) = @_; for my $barfloon ( keys %{$frumption->{'barfloon_gallery'}} ) { process_one_barfloon $barfloon; } }
Of course, you may have to profile and optimize, but most of the time I find the code runs fast enough, for some definition of "fast enough".
--
TTTATCGGTCGTTATATAGATGTTTGCA
In reply to Re: Dotted hash access
by TomDLux
in thread Dotted hash access
by sfink
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |