sub da (\@\@\@) { my ($s, $a, $b)=@_; push(@$a, shift @$s), da(@$s, @$b, @$a) if @$s } my (@a, @b); my @s=1..7; da(@s, @a, @b); print "@a - @b\n"