#!/usr/bin/perl use strict; use warnings; use Data::Dump; my %testHash; # initialize hash my $hashRef = \%testHash; # get a reference to that $hashRef->{'a'} = "Hello World!"; my $destref = \$hashRef->{'b'}; # Just a reference to the value, no dereference involved. # initialize hash element as empty array $$destref = []; # NOTE: this line is not necessary # assign a value to the hash element 'a' @{$$destref}[0] = "How"; # Assign to the dereference. @{$$destref}[1] = "are"; # Assign to the dereference. # initialize array element as empty hash @{$$destref}[2] = { }; # NOTE: this line *is* necessary @{$$destref}[2]->{'c'} = "you"; # assign values to hash @{$$destref}[2]->{'d'} = "today?"; # dd \%testHash; # Output: # { # a => "Hello World!", # b => ["How", "are", { c => "you", d => "today?" }], # }