I've been reorganizing the WWW::Mechanize documentation. I needed a way to see the organization in a nutshell, so:
use warnings;
use strict;
local $/ = ""; # paragraph mode
while ( my $para = <> ) {
next unless $para =~ s/^=head(\d)\s+//;
my $level = $1;
chomp $para;
print " " x (($level-1)*4) if $level > 1;
print "$para\n";
}
perl -pe '$_=/=head(\d) (.*)/?$"x(4*($1-1)).$2.$/:""'