Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Can the fully qualified name of a global variable be determined?

by LanX (Chancellor)
on Jan 24, 2013 at 14:59 UTC ( #1015184=note: print w/replies, xml ) Need Help??


in reply to Can the fully qualified name of a global variable be determined?

OK it's a hack. but it works out-of-the box since B::Deparse is core! =)

use B::Deparse; package TST; our $var; package main; $VARNAME='$var'; print B::Deparse->new()->coderef2text(eval "sub { $VARNAME }" );

OUTPUT:

{ $TST::var; }

And the rest is silence regex! :)

Cheers Rolf

Replies are listed 'Best First'.
Re^2: Can the fully qualified name of a global variable be determined?
by LanX (Chancellor) on Jan 24, 2013 at 16:31 UTC
    UPDATE

    But I don't know if this helps with exported vars, since IIRC "exporting" means copying a reference into the importing namespace. In other words: the current "fully qualified name" is from the importing namespace.

    If you wanna find the original full qualified name you have to parse all loaded STASHes, till you find the reference. You can find the namespaces by inspecting %main::

    print join "\n", grep {/^.*::$/} keys %main::

    -->

    Tie:: utf8:: TST:: re:: DynaLoader:: mro:: strict:: Regexp:: Term:: UNIVERSAL:: overload:: Data:: IO:: Exporter:: Internals:: warnings:: Config:: DB:: CORE:: attributes:: Scalar:: vars:: XSLoader:: B:: main:: Carp:: PerlIO:: O:: bytes::

    UPDATE

    or by checking %INC

    Cheers Rolf

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015184]
help
Chatterbox?
[LanX]: wot wot?
[thezip]: W0t n0t
[perldigious]: w4st3 n0t w0t n0t

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (12)
As of 2017-03-24 18:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (305 votes). Check out past polls.