$i = 1; %hash = ( ('abc' => 7) if (! $i), 'hk' => 5, 'jk' => 6 ); foreach $key (keys %hash) { print "the key is $key and val is $hash{$key}\n" }