in reply to Re^3: Getting Max Value from Different Hashes
in thread Getting Max Value from Different Hashes

That isn't over four values, that's over four collections each of unknown size. I was seriously considering adding this other method just because the collection size was unknown. This moves from collection-at-a-time to element-at-a-time.

my @collections = ...; my $first_collection = shift @collections; keys %$first_collection; my ( undef, $max ) = each %$first_collection; while ( my ( undef, $elt ) = each %$first_collection ) { if ( $elt > $max ) { $max = $elt; } } for my $collection ( @collections ) { keys %$collection; while ( my ( undef, $elt ) = each %$collection ) { if ( $elt > $max ) { $max = $elt; } } }

Replies are listed 'Best First'.
Re^5: Getting Max Value from Different Hashes
by polettix (Vicar) on Aug 01, 2005 at 16:13 UTC
    Maybe the OP changed the specs on the fly, but I read (bold mine):
    Given 4 distinct hashes with only one key-value
    The only uncertainty is in the fact that this only one key-value is present or not.

    Flavio
    perl -ple'$_=reverse' <<<ti.xittelop@oivalf

    Don't fool yourself.