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.my($good, $bad, $ugly)=part { /good/ ? 0 : /bad/ ? 1 : /ugly/ ? 2 : (warn "$_ didn't categorize" and 3) } @people;
sub part(&@) { my($code, @list)=@_; my @ret=(); push @{$ret[&$code()]}, $_ for @list; return @ret; }
In reply to Perl 6's part() by BrentDax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |