Thanks to BrowserUK I got on the right track looking at the B modules. I decided to narrow the problem down to finding lexical variables in modules, since almost all my variables are of this sort. I didn't see how to handle lexical variables using the techniques in B::Lint, but I ran across B::LexInfo. This just about gets me what I want, although it hasn't been tested thoroughly:
use B::LexInfo; use strict; # The name of the module to test goes in # the next two lines. my $module_name= "Data::Table"; use Data::Table; my $lexi = B::LexInfo->new; my $info = $lexi->stash_cvlexinfo($module_name); foreach my $pad (@{$info}) { foreach my $sub (keys %{$pad}) { my %lexhash; foreach my $next (keys %{$pad->{$sub}}) { if ($next =~ /(\$)(.*)/ or $next =~ /(@)(.*)/ or $next =~ /(%)(.*)/) { my ($op, $varname)= ($1,$2); if (exists $lexhash{$varname}) { print "$sub has lexicals $op$varname". " and $lexhash{$varname}$varname\n"; } else { $lexhash{$varname}= $op; } } } } }
I could make this a module and add a little more B code to it, so that it would check a whole program and all the loaded modules. I could use it with something like:
use VerifyLexicalsWontConfuseTomA;
It should work perfectly the first time! - toma

In reply to Re: Confusing variable names by toma
in thread Confusing variable names by toma

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.