http://www.perlmonks.org?node_id=997204


in reply to Subroutine Even/Odd

Another way using push and a ternary.

$ perl -Mstrict -Mwarnings -E ' > my( @odds, @evens ); > push @{ $_ % 2 ? \ @odds : \ @evens }, $_ for 1 .. 10; > say qq{ Odds: @odds}; > say qq{Evens: @evens};' Odds: 1 3 5 7 9 Evens: 2 4 6 8 10 $

I hope this is of interest.

Update: Documentation link corrected, thanks choroba :-)

Cheers,

JohnGG