in reply to Is there a way to access the name under which a subroutine was first defined?
Initially? The definitions don't carry a timestamp. It all depends on when you are doing your checks.
$\ = $/; sub foo; print "foo ref is: ",\&foo; my $ref = \&foo; for (keys %main::) { print "1: ",*{$_}{NAME} if *{$_}{CODE} and *{$_}{CODE} eq $ref; } *bar = *foo; sub foo { print "in foo" } for (keys %main::) { print "2: ",*{$_}{NAME} if *{$_}{CODE} and *{$_}{CODE} eq $ref; } bar(); __END__ foo ref is: CODE(0x91cf78c) 1: foo 2: bar 2: foo in foo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Is there a way to access the name under which a subroutine was first defined?
by ELISHEVA (Prior) on Feb 16, 2009 at 10:05 UTC | |
by shmem (Chancellor) on Feb 16, 2009 at 10:56 UTC | |
by ELISHEVA (Prior) on Feb 16, 2009 at 11:13 UTC | |
by shmem (Chancellor) on Feb 16, 2009 at 13:31 UTC | |
by ELISHEVA (Prior) on Feb 16, 2009 at 14:20 UTC |