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

The following program will find the steps between two numbers. Give it two numbers to find steps between, and the number of steps you want it to find, and it'll list them for you.

Example:

$ steps.pl 1 10 5 1, 3.25, 5.5, 7.75, 10 $ steps.pl 10.5 -10.7 4 10.5, 3.43333333333333, -3.63333333333333, -10.7

steps.pl

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

Updated to make a bit more sense. I don't always need to list it in a specific order. It makes more sense for the order to be determined by the input.