Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: New student, can we write this program in perl...

by clueless newbie (Chaplain)
on Oct 19, 2012 at 18:17 UTC ( #1000006=note: print w/replies, xml ) Need Help??


in reply to New student, can we write this program in perl...

Depending on how you interpret "two different arrays" the following might be acceptable,

#!/usr/bin/perl use strict; use warnings; my $number; # use grep to accept only the integers push(@{$number->[$_ % 2]},$_) for (grep { m{^-?\d+$} } @ARGV); # Using $" to insert ", " local $"=', '; print "The even numbers are @{$number->[0]}\n"; print "while the odd numbers are @{$number->[1]}.\n";
> perl EvenOdd.pl 1 2 -nogo 3.4 3 4 5 -4 The even numbers are 2, 4, -4 while the odd numbers are 1, 3, 5.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1000006]
help
Chatterbox?
[erix]: there used to be the 'razing' of towns and citoes but that now means something else in Germany (rasen=driving too fast)
[erix]: sleighting, I imagine 'Schlechten' will be a german word too - probably with same meaning as in dutch (breaking down, making useless a castle / defensive structure )

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2017-05-29 15:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?