my $path = 'A/B/C'; my $hr = { 'A' => {'B'=>{'C'=>'Hello'}}}; my @path = split m,$path; my $ref = $hr; while(@path){ $ref = $ref->{ shift @path } } print "$ref\n"