#!/usr/bin/perl use Benchmark qw( timethese cmpthese ); my @args = ( 100_000, { void => sub { grep { $_ == 50 } 0..100; 1 }, scalar => sub { my $res = grep { $_ == 50 } 0..100 }, list => sub { my @res = grep { $_ == 50 } 0..100 }, a_foreach => sub { my $match; foreach( 0..100 ) { $match++ if $_ == 50 } $match } } ); cmpthese( @args ); exit 0; __END__