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 |