cdfd123 has asked for the wisdom of the Perl Monks concerning the following question:
The error shows :#!/usr/bin/perl -w use strict; open(FH,"$ARGV[0]") or die; my @temp=<FH>; close FH; my $mean = Mean (\@temp); my $variance = variance(\@temp); print "$variance\n"; sub sum { my ($arrayref) = @_; my $result; foreach(@$arrayref) { $result+= $_; } return $result; } sub Mean { my ($arrayref) = @_; my $result; foreach (@$arrayref) { $result += $_ } return $result / @$arrayref; } sub variance { return (sum map { ($_ - $mean)**2 } @_) / $#_; }
Can't use string ("2.47705346386633e+16") as an ARRAY ref while "strict refs" in use at variance_try1.pl line 16.
What it mean
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: variance calculation
by FunkyMonk (Bishop) on Jan 12, 2008 at 13:47 UTC | |
|
Re: variance calculation
by graff (Chancellor) on Jan 12, 2008 at 17:24 UTC | |
by almut (Canon) on Jan 12, 2008 at 19:19 UTC | |
by cdfd123 (Initiate) on Jan 12, 2008 at 17:47 UTC | |
|
Re: variance calculation
by ady (Deacon) on Jan 12, 2008 at 17:26 UTC |