timothy adigun wrote:

[snip]

my %new_hash = ();
foreach my $data1 ( keys %$hash1 ) {
     while ( my ( $key, $value ) = each %$hash2 ) {
         my ($new_value) = keys %$value;
         $new_hash{$key} = $new_value if $data1 == $key;
     }
}

No need for the nested llops:

my %new_hash;
for my $key ( keys %hash1 ) {
    $new_hash{ $key } = each %{ $hash2{ $key } } if exists $hash2{ $key };
    }


John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to