in reply to Get a function argument's name

It might help if you post a snippet of (pseudo) code that shows what you are trying to accomplish. If the code you post actually fails to do what you want, it will be easier for us to see what it does, and maybe then we can figure out how to make adjustments so that it will do what you want.

Replies are listed 'Best First'.
Re^2: Get a function argument's name
by slaniel (Acolyte) on Jul 05, 2006 at 17:51 UTC
    Sure. I'm writing a little function to run another function on a given set of arguments and time how long it takes. Looks like so:
    sub run_and_time(&@) { use Time::HiRes; my $func = shift; my $funcName = [some bit of code to get $func's name] my $start_time = [gettimeofday]; my @retlist = &{$func}(@_); print "Time to run $funcName: ", tv_interval($start_time), "\n"; }
    So I need some way to get $funcName. Does that clarify things?
      Er, is there something wrong with Benchmark? Specifically: "timethis - run a chunk of code several times". Or maybe "timethese - run several chunks of code several times".