podoutline

petdance on 2004-11-06T04:47:07

I've been reorganizing the WWW::Mechanize documentation. I needed a way to see the organization in a nutshell, so: #!/usr/bin/perl -Tw

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"; }
which gives me nice output like: NAME VERSION SYNOPSIS IMPORTANT LINKS CONSTRUCTOR AND STARTUP new() $mech->agent_alias( $alias ) known_agent_aliases() PAGE-FETCHING METHODS $mech->get( $url ) $mech->reload() $mech->back() STATUS METHODS $mech->success() $mech->uri() $mech->response() / $mech->res() $mech->status()


Wasn't a one-liner enough?

BooK on 2004-11-07T19:29:28

perl -pe '$_=/=head(\d) (.*)/?$"x(4*($1-1)).$2.$/:""'