A programmers quick guide to Perl 5 references (presuming prior knowledges of pointers/references in some language, such as C) $a_L = \@a; # Reference to a list $a_H = \%a; # Reference to a hash # This is useful because these are now scalars, so we can easily # pass them in the parameter list and the return list foreach $i ( @$a_L ) .. # The list of the list ref foreach $k ( keys %$a_H ) .. # The hash of the hash ref $a_L->[1] # Element one of the list referred to by $a_L $$a_L[1] # Another way to do it - I like the -> construct better $a_H->{field} # Same for hashes $#$a_L # The size of the list referenced by $a_L # Let's say you want an array of hashes # This bit is nothing new $tmp_H = $a_L->[0] # Element 0 - is a hash ref $tmp_H->{field} # Reference field of the hash # A quicker way to do it: $a_L->[0]->{field} # Referencing 'field' of hash 0 $a_L->[0]{field} # Shorter typing. You only need the first '->' $a[0]{field} # This is different - we use @a, not a ref to a list # We can get more complex: $a_L->[0]->{field}->[3] # 0th element of list ref'd by $a_L is a # hash that we take 'field' from which is # a list which we get element 3 of # Or even more complex: $a_L->[0]->{$keys_L->[$a[3]]}->[3] # To deal with ambiguity, you can use {} to force the 'order' of dereferencing @{$a_L->[0]} # We want the array ref'd by the 0th element of the # array ref'd by $a_L # See 'man perldsc' for much more information, especially on making # sure that you are properly allocating space for your new creations # For example, you have to be careful doing stuff like: $a_L = \(1, 2, 3); # You probably want to do: $a_L = [1, 2, 3]; # Makes a reference to an array it creates