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

Hi,

I want to follow some use statements and BEGIN blocks stepwise, so I can see in slo-mo what's going on with importing and inheritance and whatnot. How do I do that?

Replies are listed 'Best First'.
Re: debug at compile time
by kennethk (Abbot) on Nov 14, 2008 at 15:28 UTC

    If you have a graphical environment, like ActiveState's Komodo, then that answers your question. That, of course, is pay software.

    If not, start by entering perl -D on the command line to determine if you have a full debugging version of perl. This is not the default install as it is slower and more of a memory hog. You should be able to do limited text-interface debugging without a recompile using the -d flag with the regular version. Given the complexity associated with any debugging interface, I would direct you to perldoc for more info.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: debug at compile time
by TGI (Parson) on Nov 14, 2008 at 17:47 UTC

    See perldebug, particularly the section labeled Debugging compile-time statements.


    TGI says moo

Re: debug at compile time
by ursus (Acolyte) on Nov 17, 2008 at 18:49 UTC
    Be aware that inheritance is not determined at compile-time. When you do $obj->method(ARGS), what you're actually doing is $obj->can('method')->(ARGS). can() looks something like this:
    sub can { my ($self, $meth) = @_; my $class = ref $self || $self; my $subref = *{$class . '::' . $meth}{CODE}; return $subref if defined $subref; for (@{$class . '::ISA'}) { $subref = $_->can($meth); return $subref if defined $subref; } return undef; }
    There's a lot of error-handling I've skipped, both in the definition of can() and the "expanded code" ($obj->can('method')->(ARGS)). The point is, you can modify @ISA at any time; there is no compile-time method resolution.