Reputation: 54793
Two (almost?) similar questions actually.
What is the difference between %something
and %{$something}
?
What is the difference between %{$hashvar{xyz}}
and %hashvar{xyz}
?
Upvotes: 0
Views: 122
Reputation: 15121
%something
means something
is a hash variable, and %{$something}
means that $something
is a scalar variable that contains a reference to a hash
%{$hashvar{xyz}}
means $hashvar{xyz}
(value associated with key xyz
in hash hashvar
) is a hash reference
Starting in Perl 5.20, %hashvar{xyz}
is a key/value hash slice, will return 'xyz'
and $hashvar{xyz}
; before that, it is a syntax error.
References:
perldata - Perl data types
perldsc - Perl Data Structures Cookbook
Upvotes: 4