use strict; use warnings; use feature 'say'; my $hash_ref = {}; # SCALAR pointing to an empty HASH reference my %hash = (); # actual HASH $hash{key1}{key2} = 'val1'; $hash_ref->{key1}->{key2} = 'val2'; $hash_ref = { # HASH reference, note: curly brace *** key1 => { # key1 is a nested HASH reference key2 => 'val2', # key2 is pointing to the value "val2" }, }; %hash = ( # actual HASH, note: parens *** key1 => { # key1 is a nested HASH reference key2 => 'val1', # key2 is pointing to the value "val2" }, ); # accessing "key2" in $hash_ref: say $hash_ref->{key1}->{key2}; # the first "->" is important say $hash_ref->{key1}{key2}; # accessing "key2" in %hash: say $hash{key1}{key2}; # lack of the first "->" is important say $hash{key1}->{key2}; __END__