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