use B
qw(svref_2object comppadlist class);
# perl -MO=Showlex,foo bar.pl
# to see the names of lexical variables used by &foo
# perl -MO=Showlex bar.pl
# to see the names of file scope lexicals used by bar.pl
print "$name has $count entries\n";
for ($i = 0; $i < $count; $i++) {
if (class($sv) ne "SPECIAL") {
printf "%s (0x%lx) %s\n", class($sv), $$sv, $sv->PVX;
print "$name has $count entries\n";
for ($i = 0; $i < $count; $i++) {
my ($objname, $namesav, $valsav) = @_;
shownamearray
("Pad of lexical names for $objname", $namesav);
showvaluearray
("Pad of lexical values for $objname", $valsav);
my ($objname, $obj) = @_;
$objname =~ s/^&main::/&/;
showlex
($objname, svref_2object
($obj)->PADLIST->ARRAY);
showlex
("comppadlist", comppadlist
->ARRAY);
foreach $objname (@options) {
$objname = "main::$objname" unless $objname =~ /::/;
eval "showlex_obj('&$objname', \\&$objname)";
B::Showlex - Show lexical variables used in functions or files
perl -MO=Showlex[,SUBROUTINE] foo.pl
When a subroutine name is provided in OPTIONS, prints the lexical
variables used in that subroutine. Otherwise, prints the file-scope
Malcolm Beattie, C<mbeattie@sable.ox.ac.uk>