Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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.

Replies are listed 'Best First'.
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 about the Monastery: (6)
As of 2016-10-01 18:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (5 votes). Check out past polls.