#!/usr/bin/perl -w use Benchmark; use strict; my $results = timethese( 30, { a => sub{my $total = 0; $total += $_ for(1..1e6);}, b => sub{my $total = 0; for(1..1e6){$total += $_;}}, } );