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