http://qs321.pair.com?node_id=553004


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