my $hash_reference = {}; # empty hash ref for now my $a = 'fee'; my $b = 'fie'; my $c = 'foe'; $hash_reference->{$a}{$b}{$c} = 'fum'; # same as... $hash_reference->{'fee'}{'fie'}{'foe'} = 'fum'; # same as... $hash_reference->{fee}{fie}{foe} = 'fum'; print $hash_reference->{fee}{fie}{foe};