in reply to Getting name of sub from a hash-based dispatch table?

Why do you need to know "the name"? It might have many names, and it might not even have a name, as in:
my %ops = ( '+' => sub { $_[0] + $_[1] }, '-' => sub { $_[0] - $_[1] }, '*' => sub { $_[0] * $_[1] }, );

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: •Re: Getting name of sub from a hash-based dispatch table?
by theguvnor (Chaplain) on Jan 21, 2004 at 19:37 UTC

    All the subs would have names in this situation but point conceded.

    I'd hoped though that it would be reasonably clear that the reason for knowing the name was that I wanted to use a leading underscore to mark which handler subs should be publicised and which should not. That's the only reason - I was hoping a bit of Laziness (altering my naming convention) could save me coming up with any more elaborate means of maintaining a list of which ops should be advertised. ;-)

    [Jon]