{ package Foo::Bar::Baz; our $x = 123; } #### $ns = 'Foo::Bar::Baz::'; $ref = \${ $::{$ns}{x} }; #### $ns = 'Foo::Bar::Baz'; my $stash = \%::; foreach(split '::', $ns) { $stash = $stash->{"$_\::"}; } $ref = \${ $stash->{x} }; #### { no strict 'refs'; $ref = \${ "Foo::Bar::Baz::x" }; }