# this breaks if @pathparts has a double quote in it! my $element = '$hash' . join '', map { qq|{"$_"}| } @pathparts; eval "$element = undef"; #### my $step = \%hash; while ( my $part = shift $pathparts ) { $step->{$part} ||= {}; $step = $step->{$part}; }