my $pkg_stash= do { no strict 'refs'; \%{ $pkg_name . '::' } }; #### my $package_hierarchy= mro::get_linear_isa($package_name); for my $p (@$package_hierarchy) { if (...) # check whether package $p has the variable defined }