in reply to Average Time?

use List::Util 'sum'; my $avg = sum(@times) / @times; # Dies if no times.

Replies are listed 'Best First'.
Re^2: Average Time?
by kennethk (Abbot) on Jan 27, 2009 at 16:30 UTC

    And the same with error handling:

    use List::Util 'sum'; my $avg = @times ? sum(@times)/@times : "NaN";

    As I just discovered w/ some help on CB, don't expect the above "NaN" to be NaN on MS. s/"NaN"/1e9999\/1e9999/ for portable (and less readable) support there.

    Update: ikegami is of course right that it's a C lib problem, not OS dependent, but that does not change that there are potential NaN portability issues.

      NaN support is based on the underlying C lib, not the OS.