http://www.perlmonks.org?node_id=225721

Perl 6 is slated to include a new list manipulation function, part (for partition, although Damian likes it 'cause it can mean so many other things). It takes a codeblock and a list; the codeblock returns an index, and part puts it into an arrayref corresponding to that index. For example:
my($good, $bad, $ugly)=part { /good/ ? 0 : /bad/ ? 1 : /ugly/ ? 2 : (warn "$_ didn't categorize" and 3) } @people;
If you replace the $good, $bad, and $ugly with *good, *bad, and *ugly in that example, you'll get the arrays in @good, @bad and @ugly.
sub part(&@) { my($code, @list)=@_; my @ret=(); push @{$ret[&$code()]}, $_ for @list; return @ret; }