I have an arrayref that I'd like to split into two arrays: one for elts that match a regex and one for elts that do not match.
Currently, I just do two opposite greps, but I'm sure there's a better way.
my @ok = grep { $_->name =~ m/[0-9][0-9]$/ }@{ $rec->vals }; my @no = grep { $_->name !~ m/[0-9][0-9]$/ }@{ $rec->vals };
In reply to Splitting array into two with a regex by jredburn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |