Bernardo has asked for the wisdom of the Perl Monks concerning the following question:

hi all, i have a little problem. How can i explain in a half page what the PadWalker Module is and what possibly it does ?? I've searched this on many websites but i couldn't find any good explanation. So if someone could help me with this prob i would be very grateful ! Thanks :-)

Replies are listed 'Best First'.
Re: Informations about Padwalker
by kcott (Archbishop) on Mar 10, 2013 at 22:59 UTC

    G'day Bernardo,

    Welcome to the monastery.

    I agree with the previous (Anonymous Monk) respondent in that the description in the PadWalker documentation is adequate and that you need to identify your audience (i.e. those for whom this description is inadequate).

    Furthermore, your inability to provide an explanation for your target audience suggests that the problem lies with your comprehension, rather than the documentation. Perhaps that should have been the thrust of your question, instead of a request for paraphrasing the module description. If this is, in fact, the case, then my problem becomes not knowing what part of the documentation you're having problems with. The following may help; if not, please ask for specific information or clarification.

    General/introductory documentation:

    • perlsub discusses and compares different types of variables.
    • See perlfunc for specific variable declarations, e.g. my, our and so on.
    • The LEVEL argument, used with a number of PadWalker functions, references caller.

    The Pad in PadWalker refers to scratchpad: simplistically, memory used for lexical variables. Here's some references off the top of my head; an internet search for "perl scratchpad" may provide others.

    Most of the online documentation pages have See Also links: I recommend you follow these.

    -- Ken

Re: Informations about Padwalker
by tobyink (Canon) on Mar 10, 2013 at 21:50 UTC

    Variables declared with my are private to the lexical scope they're declared in. For example...

    sub foo { my $x = 123; bar(); } sub bar { # bar cannot access variable $x } foo();

    PadWalker allows the bar sub to peek and poke at foo's private variables.

    Why is it called PadWalker? Because internally the memory structures used by Perl to keep track of lexically declared variables are called "pads". PadWalker lets you "walk" up the call stack visiting other pads.

    Using PadWalker is nearly always an incredibly bad idea. Nearly always.

    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
Re: Informations about Padwalker
by LanX (Saint) on Mar 10, 2013 at 22:21 UTC
    Package variables can be introspected by investigating the %package STASH (system table hash)

    Standard Perl has no correspondent way for lexical variables. That where PadWalker can be used.

    Cheers Rolf

Re: Informations about Padwalker
by Anonymous Monk on Mar 10, 2013 at 20:37 UTC

    How can i explain in a half page what the PadWalker Module is and what possibly it does ??

    Explain to what audience?

    The description and examples explain it well enough for me