use v5.10; use strict; use warnings; sub one2five{ state $i = -1; ++$i; return 1 + ($i % 5); } for (1..30){ printf "%d\n", one2five(); }