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

Re^3: Help with Hash of hashes, is there a better way?

by ikegami (Pope)
on Jun 01, 2006 at 09:24 UTC ( #553004=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Help with Hash of hashes, is there a better way?
in thread Help with Hash of hashes, is there a better way?

Option 2)

A callback would be simpler:

{ iterate { my ( $env_name, $platform_name, $host_name, $target_name, $total_capacity, $free_capacity, ) = @_; local $, = "\t"; local $\ = "\n"; print $env_name, $platform_name, $host_name, $target_name, $total_capacity, $free_capacity; } $stuff; }
sub iterate(&$) { my ($callback, $envs) = @_; while (my ($env_name, $platforms) = each %{$envs }) { while (my ($platform_name, $hosts ) = each %{$platforms}) { while (my ($host_name, $targets ) = each %{$hosts }) { while (my ($target_name, $target ) = each %{$targets }) { my $total_capacity = $target->{total_capacity}; my $free_capacity = $target->{free_capacity}; $callback->( $env_name, $platform_name, $host_name, $target_name, $total_capacity, $free_capacity, ); }}}} }

Tested.


Comment on Re^3: Help with Hash of hashes, is there a better way?
Select or Download Code
Re^4: Help with Hash of hashes, is there a better way?
by TeraMarv (Beadle) on Jun 01, 2006 at 10:16 UTC

    Thanks ikegami,

    I like it, very cool. Something I would never have come up with myself....well at least not this year ;-)

    That's what I love about perlmonks, you always learn something useful.

    Thanks again....to all Monks

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2014-07-10 09:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (204 votes), past polls