Maybe, dont know to be honest, but what you wrote wont compile.
For simplicity , why not just do this...
my $i = 1;
my %hash = (
'hk' => 5,
'jk' => 6
);
$hash{'abc'} = 7 if (! $i);
foreach my $key (keys %hash) {
print "the key is $key and val is $hash{$key}\n"
}