in reply to split an array in two
scalar(@_) is numbered from 1 to elements... andsub split_array_in_two { my $len = int($#_/2); return unless ( @_ ); return [ @x[0..$len] ], [ @x[$len+1..$#x] ]; }
Your code isnīt long... is readable and suficient.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: split an array in two
by salva (Canon) on Apr 28, 2005 at 09:38 UTC |