Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Match all Odd and Even Numbers

by Dr. Mu (Hermit)
on Jun 18, 2003 at 06:49 UTC ( [id://266739]=note: print w/replies, xml ) Need Help??


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";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://266739]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-18 03:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found