in reply to Sub hash param by reference
So long as your subset is a nested hashref or nested array, this works nicely. I've done something similar to spread processing across dedicated routines.
my $results = process_planet( \%world ); sub process_planet { my ( $world ) = @_; my @retval; for my $country_id ( keys %$world ) { my $population = process_country( $world->{$country_id} ) +; push @retval, { $country_id => $population }; } return \@retval; } sub process_country { my ( $country ) = @_; my $national_pop; for my $city ( keys %$country ) { $national_pop += extract_city_population( $countr->{$city} + ); } return $national_pop; }
Of course, at eavh level you have to know what you're receiving, and what you're returning.
As Occam said: Entia non sunt multiplicanda praeter necessitatem.
|
---|
In Section
Seekers of Perl Wisdom