3

I'd like to setup my project to always run the scripts through perl's Devel::Cover module. I've tried replacing the perl binary with something like this

#!/bin/sh
exec /usr/local/bin/original-perl -MDevel::Cover $@

with no success. I'd like to avoid modifying the #! for every script on my system (not the end of the world, I'd just like to figure out a more global solution).

Any thoughts on how to turn on Devel::Cover globally?

Edit: Not trying to run this in production, just trying some experiments to figure out how to split up a tightly coupled codebase. Having some automated way to see what source files are needed for a given subsystem (at least as a start) would be helpful

3
  • 3
    Why? The purpose of DC is to determine how thoroughly your tests exercise your code. It is not intended to determine which portions of it are executed under normal operation. Furthermore, running under DC slows scripts down significantly. (Just how much depends on the types of coverage you collect.) Commented May 26, 2015 at 13:49
  • If you actually want to collect what lines of code are run at all, go with Devel::NYTProf. But that might be even slower! Also those profilers all only make sense for single runs of a program. It is no good to just collect data because they write their profiles into a file that gets overwritten with each new invocation. You need to compile the report. Commented May 26, 2015 at 14:01
  • I'm not trying to do this in production. Looking at splitting up codebase and I want to get some upfront idea as to what files are involved in executing vairous subsystems. Trying to dig out from under a ball of mud. Just doing some data gathering. Commented May 26, 2015 at 15:24

1 Answer 1

7

You can set the environment variable PERL5OPT to always load -MDevel::Cover.

export PERL5OPT="-MDevel::Cover"

See perlrun for an explanation of this.


But as Michael Carman said, why would you do this? It will have significant performance costs and might not be useful if you don't run tests.

Sign up to request clarification or add additional context in comments.

4 Comments

Yup, the performance is going to be horrific. Running some experiments, not trying to make this production. :) I should have been clearer.
this works for stuff that's coming out of the webserver (which is a good portion of the code I'm working on). Not sure how to shim the export into other areas. Thanks.
@ska interesting, where did you put it? Just put it in your .bashrc and it will be available in your shells.
product I work on is an appliance ... there's code that's run as part of the post OS install ... haven't traced the OS install to see where to drop the shell var. It's somewhere I'm sure. :) Thanks for the help, getting this in the webserver has given me more than enough data to play with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.