Clear questions and runnable code
get the best and fastest answer
Re: do not understand grep exampleby BrowserUk (Patriarch)
|on Jun 15, 2012 at 17:38 UTC ( #976469=note: print w/replies, xml )||Need Help??|
The grep line my @odd_digit_sum = grep digit_sum_is_odd($_), @input numbers;
passes each number into the subroutine using $_. Within the subroutine that value is assigned to $input:
The digits of each number are then split into the array @digits
At this point, if $input is 32; then @digits contains: ( '3', '2' ).
Those digits are then summed
giving 5, and then tested to see if the result is odd:
Which in the case of 32 is true, so true is returned to grep and grep allows that input (32) through to the results array.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In Section Seekers of Perl Wisdom