Perl 6: Getting a Function Name From Inside

In Perl 6, how can I get the name of a function / routine from my body at runtime?

For instance,

sub foo { say "My name is: " ~ <WHAT-API-HERE??> ; } ... foo(); 

The above code should print:

 My name is: foo 

I looked at places like MOP , FAQ, and Functions .

+5
source share
1 answer
 sub foo { say &?ROUTINE.name } foo 

displayed:

 foo 

See Compile-time variable docs .

+6
source

All Articles