use Benchmark qw(cmpthese); my @list = (0..100); cmpthese (-3, { c_style => sub { for (my $i = 0; $i <= $#list; $i += 2) {$list[$i] = 'h1' } }, slice => sub { $_ = 'h2' for @list[map {$_ << 1} 0..$#list/2] }, modulo => sub { $_ & 1 or $list[$_] = 'h3' for 0..$#list }, doubler => sub { $list[$_ << 1] = 'h4' for 0..@list/2 }, evilgrep => sub { @list[grep{!($_&1)}0..$#list]= ('h5')x @list }, grep => sub { @list[grep{!($_&1)}0..$#list]= ('h6')x(@list/2 + 1) } }); ### RESULTS ### evilgrep 7467/s -- -19% -40% -42% -43% -65% grep 9244/s 24% -- -25% -28% -30% -57% c_style 12398/s 66% 34% -- -3% -6% -42% modulo 12811/s 72% 39% 3% -- -3% -40% slice 13211/s 77% 43% 7% 3% -- -38% doubler 21289/s 185% 130% 72% 66% 61% --