1B::Showlex(3pm)        Perl Programmers Reference Guide        B::Showlex(3pm)
2
3
4

NAME

6       B::Showlex - Show lexical variables used in functions or files
7

SYNOPSIS

9               perl -MO=Showlex[,-OPTIONS][,SUBROUTINE] foo.pl
10

DESCRIPTION

12       When a comma-separated list of subroutine names is given as options,
13       Showlex prints the lexical variables used in those subroutines.
14       Otherwise, it prints the file-scope lexicals in the file.
15

EXAMPLES

17       Traditional form:
18
19        $ perl -MO=Showlex -e 'my ($i,$j,$k)=(1,"foo")'
20        Pad of lexical names for comppadlist has 4 entries
21        0: (0x8caea4) undef
22        1: (0x9db0fb0) $i
23        2: (0x9db0f38) $j
24        3: (0x9db0f50) $k
25        Pad of lexical values for comppadlist has 5 entries
26        0: SPECIAL #1 &PL_sv_undef
27        1: NULL (0x9da4234)
28        2: NULL (0x9db0f2c)
29        3: NULL (0x9db0f44)
30        4: NULL (0x9da4264)
31        -e syntax OK
32
33       New-style form:
34
35        $ perl -MO=Showlex,-newlex -e 'my ($i,$j,$k)=(1,"foo")'
36        main Pad has 4 entries
37        0: (0x8caea4) undef
38        1: (0xa0c4fb8) "$i" = NULL (0xa0b8234)
39        2: (0xa0c4f40) "$j" = NULL (0xa0c4f34)
40        3: (0xa0c4f58) "$k" = NULL (0xa0c4f4c)
41        -e syntax OK
42
43       New form, no specials, outside O framework:
44
45        $ perl -MB::Showlex -e \
46           'my ($i,$j,$k)=(1,"foo"); B::Showlex::compile(-newlex,-nosp)->()'
47        main Pad has 4 entries
48        1: (0x998ffb0) "$i" = IV (0x9983234) 1
49        2: (0x998ff68) "$j" = PV (0x998ff5c) "foo"
50        3: (0x998ff80) "$k" = NULL (0x998ff74)
51
52       Note that this example shows the values of the lexicals, whereas the
53       other examples did not (as they're compile-time only).
54
55   OPTIONS
56       The "-newlex" option produces a more readable "name => value" format,
57       and is shown in the second example above.
58
59       The "-nosp" option eliminates reporting of SPECIALs, such as "0:
60       SPECIAL #1 &PL_sv_undef" above.  Reporting of SPECIALs can sometimes
61       overwhelm your declared lexicals.
62

SEE ALSO

64       B::Showlex can also be used outside of the O framework, as in the third
65       example.  See B::Concise for a fuller explanation of reasons.
66

TODO

68       Some of the reported info, such as hex addresses, is not particularly
69       valuable.  Other information would be more useful for the typical
70       programmer, such as line-numbers, pad-slot reuses, etc..  Given this,
71       -newlex is not a particularly good flag-name.
72

AUTHOR

74       Malcolm Beattie, "mbeattie@sable.ox.ac.uk"
75
76
77
78perl v5.34.0                      2021-10-18                   B::Showlex(3pm)
Impressum