http://www.perlmonks.org?node_id=991839


in reply to Determine steps between two numbers

Since you always assemble your steps in increasing order, you could do this:

#!/usr/bin/perl use strict; use warnings; my ($first, $second, $steps) = @ARGV; $steps = int $steps; if ($first > $second) { ($first,$second) = ($second,$first); } my $increment = ($first - $second) / ($steps - 1); my @array = ($first); for (2..$steps) { push @array, $first -= $increment; } print join(", ", @array) . "\n";