in reply to find min, max and average
However, this looks wrong:
my @values = $e->{lt};You'll get just one value. Try this for starters:
Now you have an array of all values in @values. The rest is now a piece of cake (you'll have to install Scalar-List-Utils if you don't have it already):my @values; foreach my $e (@{$data->{httpSample}}) { push @values, $e->{lt}; print "Lt_Value: ", $e->{lt}, "\n"; }
n.b. List::Util doesn't have an average() or avg() function, so I have to emulate one using sum() and dividing by the number of elements.use List::Util qw(min max sum); print "Min Lt_Value: ", min(@values), "\n"; print "Max Lt_Value: ", max(@values), "\n"; if(@values) { print "Average Lt_Value: ", (sum(@values)/@values), "\n"; } else { print "No values so no average.\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: find min, max and average
by techtween (Novice) on May 24, 2011 at 12:08 UTC | |
by Anonymous Monk on May 25, 2011 at 05:17 UTC | |
by bart (Canon) on May 25, 2011 at 07:28 UTC | |
by techtween (Novice) on May 25, 2011 at 09:52 UTC |