Reputation: 186
I have a time array list in format h:mm:ss. I want to calculate the average time of this array.
I tried below code but there is some problem with the packages. I successfully installed Duration package but now complier is throwing error on Duration::Parse package.
PS: I am using Dwinperl as the editor on windows.
use Time::Duration::Parse qw(parse_duration);
use Time::Duration qw(duration);
use List::Util qw(sum);
my $count = @time;
my $sum = sum map {parse_duration($_) } @time;
my $avg = $sum / $count;
print duration($sum, 3), "--Total Time\n";
print duration($avg, 3), "--Avg Time\n";
this is the error message that I am getting.
Can't locate Time/Duration/Parse.pm in @INC (@INC contains: C:/Dwimperl/perl/sit
e/lib C:/Dwimperl/perl/vendor/lib C:/Dwimperl/perl/lib .) at time.pl line 7.
BEGIN failed--compilation aborted at time.pl line 7.
Upvotes: 0
Views: 386
Reputation: 11713
It seems perl
could not find package Time::Duration::Parse
installed within list of @INC paths
Type following command in terminal to check if perl
can find your module by default
perldoc -l Time::Duration::Parse
If above command didn't give you installed location of desired module,
Make sure you have installed required modules
try adding following line to your perl
code to add custom installed path of module
use lib '/path/to/module';
Upvotes: 1