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; }
In reply to Re^3: Duplicate Results from Subroutine
by Koshatul
in thread Duplicate Results from Subroutine
by zenrhino
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |