in reply to Splitting array into two with a regex
sub partition (&@) { my ($condition, @array) = @_; my (@true, @false); foreach (@array) { if ( $condition->($_) ) { push @true, $_; } else { push @false, $_; } } return \@true, \@false; } my ($ok, $no) = partition { $_[0]->name =~ m/[0-9]{2}$/ } @{ $rec->val +s };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Splitting array into two with a regex
by Tanktalus (Canon) on Nov 08, 2005 at 15:10 UTC | |
by jdporter (Paladin) on Nov 08, 2005 at 16:00 UTC | |
by dragonchild (Archbishop) on Nov 08, 2005 at 17:58 UTC | |
by Roy Johnson (Monsignor) on Nov 08, 2005 at 16:33 UTC |