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; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Perl 6's part()
by jdporter (Paladin) on Jan 10, 2003 at 03:52 UTC | |
Re: Perl 6's part()
by mojotoad (Monsignor) on Jan 10, 2003 at 17:58 UTC |