summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo van der Sanden <hv@iii.co.uk>1997-03-04 11:32:11 +0000
committerChip Salzenberg <chip@atlantic.net>1997-03-01 18:40:49 +1200
commit0d72c55d125e399044812b52df01929239edc03e (patch)
treea89bf4280d7c1bea75c27d9b0b507fff6e6cae4b
parenta11f541486495a825421e9b55d08a2172f586aab (diff)
downloadperl-0d72c55d125e399044812b52df01929239edc03e.tar.gz
Benchmark: using code refs
It often irritates me that I can't supply a coderef to the Benchmark:: routines: here's a small patch to allow them. p5p-msgid: 199703041132.LAA07613@tyree.iii.co.uk
-rw-r--r--lib/Benchmark.pm4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/Benchmark.pm b/lib/Benchmark.pm
index c382fcb1c4..ee7cf74cc3 100644
--- a/lib/Benchmark.pm
+++ b/lib/Benchmark.pm
@@ -329,7 +329,9 @@ sub runloop {
last if $pack ne $curpack;
}
- my $subcode = "sub { package $pack; my(\$_i)=$n; while (\$_i--){$c;} }";
+ my $subcode = (ref $c eq 'CODE')
+ ? "sub { package $pack; my(\$_i)=$n; while (\$_i--){&\$c;} }"
+ : "sub { package $pack; my(\$_i)=$n; while (\$_i--){$c;} }";
my $subref = eval $subcode;
croak "runloop unable to compile '$c': $@\ncode: $subcode\n" if $@;
print STDERR "runloop $n '$subcode'\n" if ($debug);