3 use B qw(svref_2object comppadlist class);
8 # perl -MO=Showlex,foo bar.pl
9 # to see the names of lexical variables used by &foo
11 # perl -MO=Showlex bar.pl
12 # to see the names of file scope lexicals used by bar.pl
20 print "$name has $count entries\n";
21 for ($i = 0; $i < $count; $i++) {
24 if (class($sv) ne "SPECIAL") {
25 printf "%s (0x%lx) %s\n", class($sv), $$sv, $sv->PVX;
37 print "$name has $count entries\n";
38 for ($i = 0; $i < $count; $i++) {
45 my ($objname, $namesav, $valsav) = @_;
46 shownamearray("Pad of lexical names for $objname", $namesav);
47 showvaluearray("Pad of lexical values for $objname", $valsav);
51 my ($objname, $obj) = @_;
52 $objname =~ s/^&main::/&/;
53 showlex($objname, svref_2object($obj)->PADLIST->ARRAY);
57 showlex("comppadlist", comppadlist->ARRAY);
65 foreach $objname (@options) {
66 $objname = "main::$objname" unless $objname =~ /::/;
67 eval "showlex_obj('&$objname', \\&$objname)";
71 return \&showlex_main;
81 B::Showlex - Show lexical variables used in functions or files
85 perl -MO=Showlex[,SUBROUTINE] foo.pl
89 When a subroutine name is provided in OPTIONS, prints the lexical
90 variables used in that subroutine. Otherwise, prints the file-scope
95 Malcolm Beattie, C<mbeattie@sable.ox.ac.uk>