use List::Util 'reduce'; sub pointer_to_element { return reduce { \($$a->{$b}) } \shift, @_; }