in reply to reference symbol in calling package namespace

Alarms bells are ringing. Giant red flags are waving. There's surely a better way of doing what you are trying to do, but you haven't provided us with enough information to help you there. On the off chance that this isn't one of those cases, I'll answer your question. I pity your users and maintainers if you use it.

my $value_ref = do { no strict 'refs'; \${caller().'::value'} }; print $$value_ref, "\n";

It will only work if the variable is a package variable (our) as opposed to a lexical variable (my).

Update: Oops, I had \* instead of \$. Fixed. Tested.

Replies are listed 'Best First'.
Re^2: reference symbol in calling package namespace
by skerr1 (Sexton) on Dec 05, 2006 at 19:09 UTC
    This is a contained system and this will save more headaches than create. Simply put, we want to access information in once place that the calling namespace has. With Perl there are always better ways to do things. I don't think it is wrong however to access, in a contained system, information that you know will be there. The section is carefully commented and the code is pretty clear (at least it is now with your assistance):
    my ($pkg) = caller; my $value1 = ${$pkg . "::value1"}; my $value2 = ${$pkg . "::value2"};
    I thank you for your help. This resolves my issue.
    Shannon Kerr