in reply to "Round Robin" variable range?

G'day Salamihawk,

Welcome to the monastery.

If @range holds your range of numbers and $i is initialised to zero, you can cycle through your numbers with:

$range[$i++ % @range]

Here's my test:

#!/usr/bin/env perl -l use strict; use warnings; my @range = 1 .. 4; my $i = 0; for (1 .. 9) { print $range[$i++ % @range]; }

Output:

1 2 3 4 1 2 3 4 1

-- Ken