in reply to @h{qw(a b c)} doesn't create an @h array. It sets 3 scalar values in the %h hash.

Arrays are subscripted with []s not {}.

@hash{...} = ...; is called a hash slice. See perlreftut.


Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco.

Replies are listed 'Best First'.
Re^2: @h{qw(a b c)} doesn't create an @h array. It sets 3 scalar values in the %h hash.
by ikegami (Patriarch) on Mar 10, 2005 at 18:42 UTC

    ...which is related to array slices:

    my %hash = ( 'a' => 'A', 'b' => 'B', 'c' => 'C', ); my @array = qw( d e f ); print(join(', ', @hash{'a', 'b'} ), "\n"); # A, B print(join(', ', @array[0, 1] ), "\n"); # d, e