Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

petdance (2468)

petdance
  andy@petdance.com
http://www.perlbuzz.com/
AOL IM: petdance (Add Buddy, Send Message)
Yahoo! ID: petdance (Add User, Send Message)
Jabber: petdance@gmail.com

I'm Andy Lester, and I like to test stuff. I also write for the Perl Journal, and do tech edits on books. Sometimes I write code, too.

Journal of petdance (2468)

Friday November 05, 2004
11:47 PM

podoutline

[ #21737 ]
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()

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.