in reply to Initializing a hash using conditions
%hash = ( $i ? (abc => 7) : (), hk => 5, jk => 6, ); [download]
Anon Monk++, nice neat solution that does not create the key abc unless the condition evaluates true. However I think you switched the logic of the OP
# OP %hash = ( ('abc' => 7) if (! $i), # abc if not $i 'hk' => 5, 'jk' => 6 # Anonymonk %hash = ( $i ? (abc => 7) : (), # create abc if $i hk => 5, jk => 6, ); # /me thinks %hash = ( $i ? () : (abc => 7), # create abc if not $i hk => 5, jk => 6, ); [download]
Cheers,R.