This code splits an array in two. It seems ugly and long. Is there a better perl way? Not looking for golf, just looking to learn better idioms. Thanks!
sub split_array_in_two {
my (@x) = @_;
return ([],[]) unless @x;
my $n = (scalar @x) -1;
my $m = int ($n/2);
return ( [ @x[0 .. $m]], [ @x[($m+1) .. $n]]);
}