You should loop over all lt values and find the mininimum and maximum values, or you can cheat and use
List::Util to give you minimum and maximum from a list
However, this looks wrong:
my @values = $e->{lt};
You'll get just one value.
Try this for starters:
my @values;
foreach my $e (@{$data->{httpSample}})
{
push @values, $e->{lt};
print "Lt_Value: ", $e->{lt}, "\n";
}
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):
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";
}
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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.