in reply to Re^2: Duplicate Results from Subroutine
in thread Duplicate Results from Subroutine
So if I have this right, @_ holds the list of parameters passed to the abv subroutine.You got it, here's a version that uses the special variables $_ and @_
I flicked the if statement into a logical and, for each iteration of the foreach $_ will be the same as $cand was in the original function.sub abv { my $avg = avg(@_); my @cands = (); foreach (@_) { ($_ > $avg) and push(@cands, $_); } return @cands; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Duplicate Results from Subroutine
by choroba (Cardinal) on May 24, 2013 at 04:34 UTC |