use strict; use warnings; use Benchmark qw{ cmpthese }; my @data = map { rand( 20 ) * ( 1, -1 )[ int rand 2 ] } 1 .. 1e6; cmpthese( -10, { abs => sub { my @arr = grep { abs $_ <= 10 } @data }, two => sub { my @arr = grep { $_ >= -10 and $_ <= 10 } @data }, } );