use strict; use warnings; my ($o, $e, $n) = (1, 0); for $n (0..9) { do { print "Enter number $n : "; $_ = <STDIN>; s/\D//g; } while $_ eq ''; push @_, $_; } $n = join ' ', @_; for (0..$#_) { if ($_ % 2) { $o *= $_[$_]; } else { $e += $_[$_]; } } print "The list of numbers used is : $n\n" . "The result of adding the even elements is : $e\n" . "The result of multiplying the odd elements is : $o\n";
In reply to Re: Perl Help
by TedPride
in thread Perl Help
by Stud_Perl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |