#! perl -slw use strict; my @a = 1..3; my @b = 'a'..'f'; my @c = map chr, 33 .. 37; nFor( 3, \@a, \@b, \@c ); #3 sets the number of arrays to sift through. sub nFor { my $n = shift; #I understand shift chops off the first element in an array, but what purpose does that serve? Also, how are the arrays (@a, @b, @c) referenced in this code? if( $n ) { #what exactly is $n? for my $i ( @{ shift() } ) { # I have no idea how $i get's it's value? nFor( $n-1, @_, $i ); #why does the top nFor call for 4 variables, while this one only calls for 3? } } else { print join ' ', @_; } }