6 use B qw(svref_2object comppadlist class);
11 # perl -MO=Showlex,foo bar.pl
12 # to see the names of lexical variables used by &foo
14 # perl -MO=Showlex bar.pl
15 # to see the names of file scope lexicals used by bar.pl
23 print "$name has $count entries\n";
24 for ($i = 0; $i < $count; $i++) {
27 if (class($sv) ne "SPECIAL") {
28 printf "%s (0x%lx) %s\n", class($sv), $$sv, $sv->PVX;
40 print "$name has $count entries\n";
41 for ($i = 0; $i < $count; $i++) {
48 my ($objname, $namesav, $valsav) = @_;
49 shownamearray("Pad of lexical names for $objname", $namesav);
50 showvaluearray("Pad of lexical values for $objname", $valsav);
54 my ($objname, $obj) = @_;
55 $objname =~ s/^&main::/&/;
56 showlex($objname, svref_2object($obj)->PADLIST->ARRAY);
60 showlex("comppadlist", comppadlist->ARRAY);
68 foreach $objname (@options) {
69 $objname = "main::$objname" unless $objname =~ /::/;
70 eval "showlex_obj('&$objname', \\&$objname)";
74 return \&showlex_main;
84 B::Showlex - Show lexical variables used in functions or files
88 perl -MO=Showlex[,SUBROUTINE] foo.pl
92 When a subroutine name is provided in OPTIONS, prints the lexical
93 variables used in that subroutine. Otherwise, prints the file-scope
98 Malcolm Beattie, C<mbeattie@sable.ox.ac.uk>