Looking at the output of B::Concise, there are two extra opcodes in the block version. Compare:
$ perl -MO=Concise -e 'my $total = 0; $total += $_ for(1..1e6);'to:
$ perl -MO=Concise -e 'my $total = 0; for(1..1e6){$total += $_;}'At first glance, it looks like the opcodes manage entering and exiting the block scope.
In reply to Re: Benchmarking for loops?
by chromatic
in thread Benchmarking for loops?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |