It might be easier if you used a standard proven statistics module of which there are a number on CPAN.
For example, I have modified your code to work with the CPAN Module Statistics/Descriptive
Code:
#!/usr/local/bin/perl -w
use strict;
use Statistics::Descriptive;
open(FH, "$ARGV[0]") or die "No file specified\n";
my @temp=<FH>;
close FH;
my $stat = Statistics::Descriptive::Full->new();
$stat->add_data(\@temp);
my $mean = $stat->mean();
my $variance = $stat->variance();
my $num = $stat->count();
print "Number of Values = $num\n",
"Mean = $mean\n",
"Variance = $variance\n";