Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Is there a module that I can use in my perl scripts that will give me some kind of feedback or criticism about my code?

I am completely self taught and don't know anyone that can point out stupid flaws that I could avoid to make my scripts run better, faster, etc...

Basically I want to be able to see how long the script is running inside of each subroutine, loop, etc, so I can get an idea of where I need to look at for optimizations.

Replies are listed 'Best First'.
Re: A module that profiles a perl script?
by FunkyMonk (Chancellor) on Aug 28, 2010 at 23:54 UTC
    Perl::Critic is what you seem to be looking for. Devel::NYTProf is what you seem to be asking for.

    Critic will criticise your code and NYTProf will profile (tell you where your slow bits are) it.

    I am completely self taught and don't know anyone that can point out stupid flaws that I could avoid to make my scripts run better, faster, etc...
    The perlfaqs are a good read too. They're very long, so just take them a bit at a time.

    update: added the quote and it's answer

Re: A module that profiles a perl script?
by toolic (Bishop) on Aug 29, 2010 at 00:08 UTC
Re: A module that profiles a perl script?
by murugu (Curate) on Aug 29, 2010 at 01:29 UTC
Re: A module that profiles a perl script?
by locked_user sundialsvc4 (Abbot) on Aug 30, 2010 at 15:42 UTC

    Also, I am mindful of one of the many admonitions in The Elements of Programming Style:

    “Don’t diddle the code to make it faster: choose a better algorithm.”

    It is very frequently the case that, whatever you might be doing, it has already been done before.   Hence, perhaps the single most important thing to do, especially at the start of a project, is “due diligence.”   Search CPAN thoroughly and carefully.   These modules are generally well-crafted and known to work.   Your “programming” almost devolves into “stringing them together.”   And the best response to TMTOWTDI is ... “pick one and do it.”