$ perl -MO=Deparse -e '$hash->$*->{"key1"}{"$var2"} = $value' $$hash->{'key1'}{"$var2"} = $value; -e syntax OK