in reply to Name of caller if aliased?

So you too ended playing with symbol table..:=)

If i understand, and you know i'm still learning, when caller (and i suspect every other trick) starts, the lookup in the symbol table is done and you cannot access anymore the name: you have the right part of the alias assignation.

As i understand you want something like (using the web analogy) to $ENV{HOST} or $ENV{REFERRER} to identify the original name or if you had been redirected: I dont think such introspection exists in Perl (i hope i'm wrong).

I think you can only do the opposite thing: given your show function you can look in the symbol table to collect any enrty that point to the same code.

L*
update: for future reader here the ouput of a playground i working on that shows the alias thing:
CODE PASSED TO EVAL: package LanX { $\="\n"; sub show { print join "\t",(caller(0))[0..3]; }; *func = \&show; } PACKAGE: main::LanX:: (2 names defined) ---------------------------------------------------------------------- +- main::LanX::func ---------------------------------------------------------------------- +- scalar x array hash code x io format name x package x ---------------------------------------------------------------------- +- main::LanX::show ---------------------------------------------------------------------- +- scalar x array hash code x io format name x package x Package Gymnasium>inspect LanX show code main::LanX::show {CODE} slot main namespacetest10.pl 100 LanX::show main namespacetest10.pl 100 LanX::show 1 Package Gymnasium>inspect LanX func code main::LanX::func {CODE} slot main namespacetest10.pl 100 LanX::show main namespacetest10.pl 100 LanX::show 1
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: Name of caller if aliased?
by LanX (Saint) on Feb 25, 2015 at 14:11 UTC
    > given your show function you can look in the symbol table to collect any enrty that point to the same code.

    Yes I could parse the stash of the calling package and compare the CODE-slots to identify aliases.

    But apart from the overhead, the results won't be necessarily unique.

    $\="\n"; sub show { print join "\t",(caller(0))[0..3]; }; show(); package Test; *func = \&main::show; *funk = \&main::show; func(); funk();

    /usr/bin/perl -w /tmp/tst.pl main /tmp/tst.pl 6 main::show Test /tmp/tst.pl 13 main::show Test /tmp/tst.pl 14 main::show

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)

    PS: Je suis Charlie!