Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Sub hash param by reference

by TomDLux (Vicar)
on Jul 11, 2016 at 19:58 UTC ( [id://1167575]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1167575]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2025-07-20 01:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.