I was going through the book intermediate perl and came across the
following code.
my @odd_digit_sum = grep digit_sum_is_odd($_), @input_numbers;
sub digit_sum_is_odd {
my $input = shift; ------------> what are we doing here?
my @digits = split //, $input; # Assume no nondigit
characters
my $sum;
$sum += $_ for @digits; ---------> what exactly is the
operation performed here? specially haven't understood "for"
return $sum % 2;
}
Appreciate your inputs.
+Vishnu
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/