#! /bin/perl use Data::Dumper; my $hash = { 'wheels' => { 'four' => { 'car' => { 'plain' => { 'sporty' => 'honda', 'retro' => 'volkswagon', }, 'fancy' => { 'red' => 'ferrari', 'silver' => 'maserati', }, }, 'truck' => { 'light' => { 'chevy' => 'pickup', }, 'utility' => { 'us' => 'mail', 'city' => 'trash', 'muni' => 'power', 'corp' => { 'dom' => 'dominion power', 'vap' => 'virginia power', }, }, }, }, 'one' => 'Unicycle', 'two' => { 'pedals' => 'bicycle', 'motorized' => 'motorcycle', }, 'three' => 'tricycle', } }; ##--------------------------- ## DEEP REFERENCE ##--------------------------- fetch2($hash, 'wheels'); fetch2($hash, 'wheels', 'four', 'truck'); fetch2($hash, 'wheels', 'four', 'truck', 'utility'); fetch2($hash, 'wheels', 'four', 'truck', 'utility', 'blah'); fetch2($hash, 'wheels', 'four', 'truck', 'utility', 'corp', 'dom'); ## Using your suggested technique sub fetch2 { my ($hash, @keys) = @_; print "==> Fetching [" . join(', ', @keys) . ']' . "\n"; my $command_string = 'print Dumper $hash->' . '{shift @keys}' x scalar @keys; eval "$command_string"; }