#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %hash; my $a="{5}{6}"; # path to insert # trying to get $hash{root}{1}{5}{6}{2}="b"; $hash{root}{1}{$a}{2}="b"; print Dumper(%hash);