in reply to Initializing a hash using conditions
I recommend the inline ternary solutions that you've
recieved. I post because those solve your immediate problem but don't address
the fundamental problem with your code:
The primary problem is that you are placing a statement where an expression is expected. A general solution to this problem is to use a do BLOCK that ends with the value you want.
Be well,%hash = ( do{ if ( $i) { abc => 7 } else { } }, );
|
|---|