linuxfan has asked for the wisdom of the Perl Monks concerning the following question:
I have an array with 20 subrefs. I go through each element of the arrray and execute the subroutine. Sometimes, I have to remove a few subrefs from the array and run my program. As a result, I find it hard to trace the name of the subroutine currently running. My code looks like:
As you can see, each time I change the elements of the array, the test # printed on STDERR is different from the subroutine that is actually running.my @tests = (\&test1,\&test2,\&test3,&test4); # 20 odd refs here my $test = 1; foreach my $subref (@tests) { print STDERR "Test # $test++\n"; foreach my $size (1..1000) { $subref->($arg1,$arg2,$size); } }
Is there a way I can obtain the name of the subroutine currently running? (like test1, test2 etc.).
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: getting subroutine names
by merlyn (Sage) on Jan 13, 2005 at 01:44 UTC | |
by linuxfan (Beadle) on Jan 13, 2005 at 02:13 UTC | |
|
Re: getting subroutine names
by xdg (Monsignor) on Jan 13, 2005 at 02:21 UTC | |
by linuxfan (Beadle) on Jan 13, 2005 at 18:41 UTC | |
|
Re: getting subroutine names
by broquaint (Abbot) on Jan 13, 2005 at 03:26 UTC | |
|
Re: getting subroutine names
by gopalr (Priest) on Jan 13, 2005 at 02:08 UTC |