A list can only contain scalar values, for example: ( 1, 'a', [], {}, sub{}, $scalar, \$scalar, \@array, \%hash, \&subroutine, \*type_glob ), (a number, a string, an anonymous array, an anonymous hash, an anonymous subroutine, a scalar variable, a reference to a scalar variable, a reference to an array, a reference to a hash, a reference to a subroutine, a reference to a type glob.)
In Example 1 you are assigning an anonymous hash to an hash, which is the same as saying my %h = {}; or my %h = 'a'; or my %h = 1;. You need to assign a list with an even number of elements.
In Example 2 you are assgning a list of eight elements to the hash. Unfortunately two of the keys are the same as the other two keys so only the last two unique keys are saved to the hash.
Example 3 is basically the same as Example 1.
In reply to Re: Difference in Hash Declaration
by jwkrahn
in thread Difference in Hash Declaration
by perl@1983
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |