in reply to Re^14: Why? (each...)
in thread Why? (each...)

The context is %hash, not $hash. The mistake in the OP was using {} when he should have used ().

Elda Taluta; Sarks Sark; Ark Arks

Replies are listed 'Best First'.
Re^16: Why? (each...)
by ikegami (Patriarch) on May 16, 2011 at 18:23 UTC

    The context is actually "I still am fuzzy about the difference between “square brackets,” “braces,” and “parentheses.”".

    You said parens indicate a list, so that would mean %hash should be used.

    sub g { return { ... } } sub h { return { ... } } my %hash = (f ? g : h);

    That's wrong wrong wrong.

      I took the context to be like how it was used in the OP -- i.e. something like "When declaring and initializing hashes (%) and arrays (@), do I use {}, [], or () to assign the values?".

      Elda Taluta; Sarks Sark; Ark Arks

        One never uses {} or [] to initialise a hash or array. No need to make stuff up about ().