Re: FQN from references
From: Wiggins D'Anconia (wiggins_at_danconia.org)
Date: 10/23/03
- Next message: Pitsword: "Windows Patches and Perl"
- Previous message: Simran: "Re: Making a simple calculator with perl"
- In reply to: Sharad Gupta: "FQN from references"
- Next in thread: Steve Grazzini: "Re: FQN from references"
- Reply: Steve Grazzini: "Re: FQN from references"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 22 Oct 2003 20:22:47 -0500 To: "Gupta, Sharad" <Sharad.Gupta@netapp.com>
Gupta, Sharad wrote:
> Hi All,
>
> How do i know the full name of a variable from its reference??.
>
> Say i have a routine defined like this:
>
> package Bar;
> sub foo {};
>
> And then i say:
> my $x = \&foo;
>
> Now from this coderef ($x) i want to know its fully qualified name which would be somthing like Bar::Foo.
> Is there a way to do that.??.
>
Where do you want to know it? Presumably if you have set it then you
should know it already, if it is set dynamically you still have to have
the name somewhere that you can access, then it is just a matter of
storing it smartly, aka rather than using
my $x = \&foo;
Why not:
my %handler;
$handler{'Bar::Foo'} = \&foo;
Now you can access the reference and have its name at the same time. The
problem comes in with inheritance because maybe $y wants to call $x
(foo) and thinks it is in Bar but it really is in Baz, does this mean it
shouldn't be called, or just that it was inherited and it is ok to call?
Within foo, there is __PACKAGE__ which will give you Bar...
You may also want to have a look at Symbol Tables in perldoc perlmod....
Gurus, am I missing out on something?? ;-)
- Next message: Pitsword: "Windows Patches and Perl"
- Previous message: Simran: "Re: Making a simple calculator with perl"
- In reply to: Sharad Gupta: "FQN from references"
- Next in thread: Steve Grazzini: "Re: FQN from references"
- Reply: Steve Grazzini: "Re: FQN from references"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|