in reply to split an array in two
orsub split_array_in_two { ([splice @_, @_/2], \@_)[1,0] }
or the funny recursive way:sub split_array_in_two { my $l=@_/2; [@_[0..$l-1]], [@_[$l..$#_]] }
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"
|
|---|