13 Mar 2022 08:40:18 UTC
- Distribution: perl
- Module version: 1.05
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (2152)
- KwaliteeBus factor: 15
- License: perl_5
- Download (17.35MB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:211 non-PAUSE users
B::Showlex - Show lexical variables used in functions or files
perl -MO=Showlex[,-OPTIONS][,SUBROUTINE] foo.pl
When a comma-separated list of subroutine names is given as options, Showlex prints the lexical variables used in those subroutines. Otherwise, it prints the file-scope lexicals in the file.
$ perl -MO=Showlex -e 'my ($i,$j,$k)=(1,"foo")' Pad of lexical names for comppadlist has 4 entries 0: (0x8caea4) undef 1: (0x9db0fb0) $i 2: (0x9db0f38) $j 3: (0x9db0f50) $k Pad of lexical values for comppadlist has 5 entries 0: SPECIAL #1 &PL_sv_undef 1: NULL (0x9da4234) 2: NULL (0x9db0f2c) 3: NULL (0x9db0f44) 4: NULL (0x9da4264) -e syntax OK
$ perl -MO=Showlex,-newlex -e 'my ($i,$j,$k)=(1,"foo")' main Pad has 4 entries 0: (0x8caea4) undef 1: (0xa0c4fb8) "$i" = NULL (0xa0b8234) 2: (0xa0c4f40) "$j" = NULL (0xa0c4f34) 3: (0xa0c4f58) "$k" = NULL (0xa0c4f4c) -e syntax OK
New form, no specials, outside O framework:
$ perl -MB::Showlex -e \ 'my ($i,$j,$k)=(1,"foo"); B::Showlex::compile(-newlex,-nosp)->()' main Pad has 4 entries 1: (0x998ffb0) "$i" = IV (0x9983234) 1 2: (0x998ff68) "$j" = PV (0x998ff5c) "foo" 3: (0x998ff80) "$k" = NULL (0x998ff74)
Note that this example shows the values of the lexicals, whereas the other examples did not (as they're compile-time only).
-newlexoption produces a more readable
name => valueformat, and is shown in the second example above.
-nospoption eliminates reporting of SPECIALs, such as
0: SPECIAL #1 &PL_sv_undefabove. Reporting of SPECIALs can sometimes overwhelm your declared lexicals.
Some of the reported info, such as hex addresses, is not particularly valuable. Other information would be more useful for the typical programmer, such as line-numbers, pad-slot reuses, etc.. Given this, -newlex is not a particularly good flag-name.
|s||Focus search bar|
|?||Bring up this help dialog|
|g p||Go to pull requests|
|g i||go to github issues (only if github is preferred repository)|
|g a||Go to author|
|g c||Go to changes|
|g i||Go to issues|
|g d||Go to dist|
|g r||Go to repository/SCM|
|g s||Go to source|
|g b||Go to file browse|