in reply to Match all Odd and Even Numbers

I'm posting this just because the idiom is nifty, not because I want to help with your homework.

push @{$_ & 1 ? \ @odd : \ @even }, $_ for @nums;

Added

@nums = 1..20; /.*(?=.)([13579]$)?(?(1)(?{${"\@nums::${_}::"}++})|(?{${"\@nums::${_}: +:"}--}))/ for @nums; printf "%d %s\n", $_, ${"\@nums::$_"} > 0 ? odd : even for keys %{"\@n +ums::"};