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

Hi All,
  I've been doing an awful lot of code recently. Updating a fairly large program (over 10,000 lines of perl). One of the big things I'm changing is the way variables are named and set in the configuration system and throughout the code.
I'm getting near the end of it, and I was about to write a script to check all the code (broken into several files) collect details on all the variables used how often they occur, where they occur, etc. So that I can quickly see if I've missed anything major or if some variables are misnamed, etc.
The thought occurred to me that this would make a useful tool for other people so I planned on making it into a CPAN module.
The further thought occurred that it seems like quite an obviously useful tool that someone else has probably already done something like it, and it's already on CPAN, but I just can't find it.


So I was hoping that someone here would know if something that does this exists and be able to point me to it.

Lyle
  • Comment on Generating report on variables and alike...

Replies are listed 'Best First'.
Re: Generating report on variables and alike...
by Fletch (Bishop) on Apr 21, 2008 at 02:23 UTC

    Perhaps Perl::Critic could be cajoled into doing what you want with a suitable policy?

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      This might be nice. If it's not already there somewhere, it would be great to have useless variable names like %data or rampant single letter names flagged as sub-optimal.

        Except as loop indices or as part of mathematical functions such as if ($x^2 + $y^2 == $z^2) { ... }. And, useless variables are only useless outside of context. %data might be perfectly acceptable in a properly-named function.

        My criteria for good software:
        1. Does it work?
        2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
      This looks good. But I'm wieghing up the time it'll take to understand Perl::Critic to putting a qnd script together.
Re: Generating report on variables and alike...
by TOD (Friar) on Apr 21, 2008 at 02:22 UTC
    what about the B::xxx modules? perhaps B::Terse will be what you have in mind.
    --------------------------------
    masses are the opiate for religion.
      sry, i have to correct myself. take a look at B::Showlex.
      --------------------------------
      masses are the opiate for religion.
        Strangely enough when I use the -newlex option it doesn't list any of the variables. But when I use it without the -newlex option it shows me all of them. Problem is that for my purposes I need to see all the variables names... Can't figure out why the newlex isn't working right...