Hey,guys I have to create the subroutine that will take the even and odd numbers from an array and print them out but I Haven't been able to combine the 2 into 1 this is what I have
I know there's an easier way to do it but I always complicate my program I would appreciate any help I can get.sub even { my @a = @_; foreach $number(@a) { if($number%2==1) { $number = $_; } print "$number"; } print " = Even numbers\n"; } sub odd { my @a = @_; foreach my$number (@a) { if($number%2==0) { $number = $_; } print "$number"; } print "= odd numbers\n"; }
In reply to Subroutine Even/Odd by perlguru22
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |