#!/usr/bin/perl my %hash1 = ( key1 => val1, key2 => val2, key3 => val3, key4 => val4, key5 => val5); my %hash2 = ( key1 => xxxval1, key2 => xxxval2); out:foreach my $key (keys %hash1) { foreach my $inkey (keys %hash2) { if($key eq $inkey) { $hash1{$key} = $hash2{$inkey}; next out; } } }