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

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;
}
}

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.

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

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

Creates the indentation helper, but does not install it yet.
If given a single argument it is assumed to be for the message attribute.
Output a warning with the previous installed hook.
Indent a message.
Calls format and then emit.
Calls install the hook and outputs the optional message.
Calls uninstall the hook and outputs the optional message.
Installs the hook in $SIG{__WARN__}.
Uninstalls the hook restoring the previous value.

If supplied will be printed in enter prefixed by enter_string and in leave prefixed by leave_string.
Defaults to ' ' (four spaces).
Defaults to ' -> '.
Defaults to ' <- '.
