#!/usr/bin/perl -w use strict; use Benchmark; sub step1 { my $step = shift; @_[map {$_ * $step} 0..($#_ / $step)]; # curious what effect the backets would have } sub step2 { my $step = shift; @_[map {$_ * $step} 0..$#_ / $step]; } sub step3 { my $step = shift; return map { $_[$_] } grep { $_ % $step == 0 } 0..$#_; } my @array = (0..1000000); timethese(-10, { 'Step 1' => 'step1(500000, @array)', 'Step 2' => 'step2(500000, @array)', 'Step 3' => 'step3(500000, @array)' });