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 useful, but often too much trouble to have your traces indented.

This module makes it easy - call the indent function, and keep the thing you got back around until the sub exits.

This will wrap $SIG{__WARN__} with something that adds as many repetitions of $Devel::STDERR::Indent::STRING as there are live instances of the class (minus one):

s/^/$STRING x ($count - 1)/ge

When the handle is destroyed (due to garbage collection), $count is decremented.

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

$STRING

The string to repeat (defaults to "\t").

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 106:

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

Around line 119:

=back without =over