use strict; use warnings; my $stuff = [ 'a', 'b', 'c', 'd' ]; sub cyclist { my $array = shift; my $pos = -1; return sub { return $$array[++$pos % @$array]; } } my $cyclestuff = cyclist $stuff; print $cyclestuff->() for 1..30; print "\n"; $$stuff[0] = 'A'; print $cyclestuff->() for 1..30; print "\n";