in reply to Confusing variable names
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 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; } } } } }
It should work perfectly the first time! - tomause VerifyLexicalsWontConfuseTomA;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Confusing variable names
by aquarium (Curate) on May 05, 2003 at 21:54 UTC | |
by dragonchild (Archbishop) on May 06, 2003 at 14:07 UTC |