PadWalker is a module which allows you to inspect (and even change!)
lexical variables in any subroutine which called you. It will only
show those variables which are in scope at the point of the call.

PadWalker is particularly useful for debugging. It's even used by
Perl's built-in debugger. (It can also be used for evil, of course.)

I wouldn't recommend using PadWalker directly in production code,
but it's your call. Some of the modules that use PadWalker internally
are certainly safe for and useful in production.

Homepage:
https://metacpan.org/release/PadWalker
