Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Statistic in Perl(Using Subroutines)

by jwkrahn (Monsignor)
on Jul 10, 2013 at 23:09 UTC ( #1043587=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub average {
    @_ == 1 or die ('Sub usage: $average = average(\@array);');
    ...
    foreach (@$array_ref) { $sum += $_; }
    return $sum / $count;
    }
    
  2. or download this
    sub average {
        ref( my $array_ref = $_[ 0 ] ) eq 'ARRAY'
    ...
        return $sum / @$array_ref;
        }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043587]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2015-07-04 13:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls