in reply to Splitting array into two with a regex

Another Way To Do It, with a single grep (and a little trick):
my @no; my @ok = grep { $_->name =~ m/[0-9][0-9]$/ or !push(@no, $_) }@{ $rec- +>vals };

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: Splitting array into two with a regex
by reasonablekeith (Deacon) on Nov 08, 2005 at 16:12 UTC
    well, if you're going to do that, you might as well stick it on one line...
    my (@ok, @no) = grep { $_->name =~ m/[0-9][0-9]$/ or !push(@no, $_) }@ +{ $rec->vals };
    ... hmmmm, perhaps not :)

    Update: Definitely not. As Roy Johnson kindly pointed out, @no will not exist in time to be pushed to in the grep.
    ---
    my name's not Keith, and I'm not reasonable.