Anno Siegel <> wrote:
>Stuart Kendrick <> wrote in comp.lang.perl.misc:
>>
>> I would like to see "&foo" instead of "&CODE(0x815bed0)".
>
>You can't. A sub can be anonymous, it can also be reachable through
>more than one name. In the first case, there simply is no name, in
>the second, which one should it print?
You can, actually - the debugger manages it. It just makes up a name
for anon subs:
DB<1> sub a { print "Hello" }
DB<2> $a = \&a
DB<3> x $a
0 CODE(0x31f17

-> &main::a in (eval 6)[/home/mjtg/perl-5.8.1-RC4/lib/perl5db.pl:618]:2-2
DB<4> $a = sub { print "Goodbye" }
DB<5> x $a
0 CODE(0x336c30)
-> &main::__ANON__[(eval 10)[/home/mjtg/perl-5.8.1-RC4/lib/perl5db.pl:618]:2] in (eval 10)[/home/mjtg/perl-5.8.1-RC4/lib/perl5db.pl:618]:2-2
DB<6>
To see how the trick is performed, rummage in the source of the debugger.
Mike Guy