bluethundr has asked for the wisdom of the Perl Monks concerning the following question:
-----------------------------#!/usr/bin/perl -w use strict; sub avg { my $total; foreach (@_) { $total += $_; } print "This is the value of \$total: $total \n "; my $num = (@_); print "This is the value of \$num: $num \n"; return $total / $num; } sub above_avg { my $tot_avg = &avg(@_); print "This is the value of \$tot_avg $tot_avg \n"; my @product; foreach (@_) { if ($_ > $tot_avg) { (@product) = $_; } } print "This is the value of \@product @product \n"; return @product; } print "Please enter a series of numbers: "; my @entered = (<STDIN>); print "Here are the numbers above the average: ", &above_avg(@entered) +, "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: array does not accept more than one number
by ikegami (Patriarch) on Dec 09, 2008 at 23:55 UTC | |
by Bloodnok (Vicar) on Dec 10, 2008 at 11:41 UTC | |
|
Re: array does not accept more than one number
by graff (Chancellor) on Dec 10, 2008 at 02:34 UTC |