sub step { my $step = shift; return grep {($_ - $_[0]) % $step == 0} @_ } foreach (step 5, 2 .. 100) { print "$_ " } #### 2 7 12 17 22 27 32 37 42 47 52 57 62 67 72 77 82 87 92 97