foreach (keys %hash1) { ... # here you would use $_ as the variable for the keys }