for my $i ( 1 .. $#array1 ) { for my $j ( 1 .. $#array1 ) { print "$i $j\n"; } }