I am new to Perl and I am trying to generate a coverage report for a Perl script I had. I followed the steps mentioned here to install Devel-Cover https://code.activestate.com/ppm/Devel-Cover/ and ran
perl -MDevel::Cover script
I get some coverage info and that message
Pod coverage is unavailable. Please install Pod::Coverage from CPAN.
Then running command cover
to generate the report I get cover: Command not found.
Tring to run cpan install Pod::Coverage
as stated by the output but it fails. I am not sure what I am missing here.
I tried using Devel::Coverage too using
perl -d:Coverage script
But I got that output
Can't locate Devel/Coverage.pm in @INC (you may need to install the Devel::Coverage module) (@INC contains: /spiratech/tools/perllib /home/mmaher/.cache/activestate/02540130/lib/perl5/site_perl/5.32.0/x86_64-linux /home/mmaher/.cache/activestate/02540130/lib/perl5/site_perl/5.32.0 /home/mmaher/.cache/activestate/02540130/lib/perl5/5.32.0/x86_64-linux /home/mmaher/.cache/activestate/02540130/lib/perl5/5.32.0).
BEGIN failed--compilation aborted.
%!s(<nil>)
and I couldn't find any instructions on how to install it. I am using Perl v5.32.0
Zeroth, ActiveState's PPM is old stuff. They have a new State Tool to handle all of that. Note that this is for using their Perl packages. If you aren't using ActiveState's perl, don't use their instructions.
First, you only need Pod::Coverage if you want to check that all of your public subroutines are documented. It's an optional feature.
Second, there's no
install
command tocpan
. Just list the modules that you want or use the command line options. With no options, the-i
(for install) is assumed:Third, the
-d
switch for debugging assumes that you are loading a module under theDevel
namespace. That's why-d:Coverage
looks forDevel::Coverage
, which it then cannot find.To load any module that you like, you can use the
-M
switch. This takes the entire module name:Lastly, once you install
Devel::Cover
, look where you installedcover
and ensure that that directory is in yourPATH
.