use strict; use warnings; my $valueM = 'myvalue'; my $hashref; $$hashref{mainKey}{$valueM}{key} = 'value'; #### my %hash; $hash{key} = 'value'; ...