#!/usr/bin/perl my @box1 = ( [ qw/a b c d e f g/ ], [ qw/h i j k l m n/ ], [ qw/o p q r s t u/ ], ); my @box2 = ( [ qw/01 02 03 04 05 06 07/ ], [ qw/20 21 22 23 24 25 08/ ], [ qw/19 32 33 34 35 26 09/ ], [ qw/18 31 30 29 28 27 10/ ], [ qw/17 16 15 14 13 12 11/ ], ); my $iter1 = iterator( \@box1 ); while ( my $x = $iter1->() ) { print "$x "; } print "\n"; $iter2 = iterator( \@box2 ); while ( my $x = $iter2->() ) { print "$x "; } print "\n";