Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: getting subroutine names

by broquaint (Abbot)
on Jan 13, 2005 at 03:26 UTC ( #421861=note: print w/replies, xml ) Need Help??


in reply to getting subroutine names

If you don't mind using a bit of black magic and have a relatively recent version of perl (5.7+ perhaps?) then you could use this code
use B 'svref_2object'; sub name_from_coderef { return svref_2object($_[0])->GV->NAME; } my @tests = (\&test1,\&test2,\&test3,\&test4); # 20 odd refs here my $test = 1; foreach my $subref (@tests) { warn sprintf "Test # %s\n", name_from_coderef($subref); foreach my $size (1..1000) { $subref->($arg1,$arg2,$size); } }
HTH

_________
broquaint

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://421861]
help
Chatterbox?
[Corion]: marto: Yep, but I didn't make it up north, sorry ;)
[Corion]: But LPW was enjoyable, even though it's always a bit hectic due to cramming everything into one day
[Corion]: I have no feeling about how my talk was received, but I'm happy with it, which counts the most to me ;-D
[Corion]: Also, London is always a nice visit, as I got to meet a friend there, and spent some time offline, working on "minor" features of the shadertoy thing ;)
[marto]: maybe next year when the kids are a little older I'll have time to attend perl events in Europe

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2016-12-07 09:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (125 votes). Check out past polls.