Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^2: how to get a subroutine name?

by clueless newbie (Chaplain)
on Jun 26, 2013 at 12:49 UTC ( #1040773=note: print w/replies, xml ) Need Help??

in reply to Re: how to get a subroutine name?
in thread how to get a subroutine name?

5.16 added __SUB__ for this purpose.

My bad! It returns a coderef.

Replies are listed 'Best First'.
Re^3: how to get a subroutine name?
by hdb (Monsignor) on Jun 26, 2013 at 12:54 UTC

    However, __SUB__ returns a reference to the currently running subroutine according to perlsub. Not sure how you will get its name?


      Still, that's rather a roundabout way to do things.

      package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1040773]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2018-07-17 02:44 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (353 votes). Check out past polls.