in reply to Match all Odd and Even Numbers

++ to all who gave encouragement and/or pointers to additional info. -- to all who posted an answer. Hey guys, sometimes pedagogy needs to take precedence over ego!

Replies are listed 'Best First'.
Re: Re: Match all Odd and Even Numbers
by Dru (Hermit) on Jun 18, 2003 at 13:00 UTC
    Thanks for all your guidance. I got it working using this code:
    for (@nums){ if ($_ % 2) { push (@odd, $_); } else { push (@even, $_); } }

      Do you mind to use below code

      my $num= [1 .. 100]; my (@even,@odd); map{0==$_%2 ? push(@odd,$_):push(@even,$_)} @$num; print "@even and @odd";