summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);