in reply to array does not accept more than one number
Assignments (as in "@product = ...;") replace the current contents of the variable to which data is being assigned. You need push here.
As an extra exercise, you should replace "foreach (@_) { if ($_ > $tot_avg) { ... } }" with a call to grep.
You should also look into separating I/O from computation. avg and above_avg shouldn't print anything.
Why are you using "&" in front of subroutine calls? That tells Perl to ignore the subroutine's prototype. Do you have a reason to do that?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: array does not accept more than one number
by Bloodnok (Vicar) on Dec 10, 2008 at 11:41 UTC |