in reply to Re^3: Splitting array into two with a regex
in thread Splitting array into two with a regex
sub partition (&\@\@\@) { my ($cond, $start, $true, $false) = @_; for (@$start) { push @{ $cond->() ? $true : $false }, $_; } return; } my @arr = 1 .. 9; my (@greater, @less); partition { $_ > 5 } @arr => @greater, @less; print "@greater\n@less\n";
|
|---|