יובל קוג'מן (Yuval Kogman)

NAME

Devel::STDERR::Indent - Indents STDERR to aid in print-debugging recursive algorithms.

SYNOPSIS

        use Devel::STDERR::Indent qw/indent/;

        sub factorial {
                my $h = indent; # causes indentation

                my $n = shift;
                warn "computing factorial $n"; # indented based on call depth

                if ($n == 0) {
                        return 1
                } else {
                        my $got = factorial($n - 1);
                        warn "got back $got, multiplying by $n";
                        return $n * $got;
                }
        }

DESCRIPTION

When debugging recursive code it's very usefl to indent traces, but often too much trouble.

This module makes automates the indentation. When you call the indent function the indentation level is increased for as long as you keep the value you got back. Once that goes out of scope the indentation level is decreased again.

EXPORTS

All exports are optional, and may be accessed fully qualified instead.

indent

Returns an object which you keep around for as long as you want another indent level:

        my $h = $indent;
        # ... all warnings are indented by one additional level
        $h = undef; # one indentation level removed

Instantiates a new indentation guard and calls enter on it before returning it.

Parameters are passed to new:

        indent "foo"; # will print enter/leave messages too

METHODS

new

Creates the indentation helper, but does not install it yet.

If given a single argument it is assumed to be for the message attribute.

emit

Output a warning with the previous installed hook.

format

Indent a message.

warn

Calls format and then emit.

enter

Calls install the hook and outputs the optional message.

leave

Calls uninstall the hook and outputs the optional message.

install

Installs the hook in $SIG{__WARN__}.

uninstall

Uninstalls the hook restoring the previous value.

ATTRIBUTES

message

If supplied will be printed in enter prefixed by enter_string and in leave prefixed by leave_string.

indent_string

Defaults to ' ' (four spaces).

enter_string

Defaults to ' -> '.

leave_string

Defaults to ' <- '.

VERSION CONTROL

http://nothingmuch.woobling.org/code

4 POD Errors

The following errors were encountered while parsing the POD:

Around line 220:

You forgot a '=back' before '=head1'

Around line 235:

=back without =over

Around line 239:

Unknown directive: =over1

Around line 241:

'=item' outside of any '=over'